Undefined property:bases_access-in_array() expects parameter 2 to be array,null given

hi!

I have some code in an onBeforeUpdate event. The code does all selects, updates and inserts well so far I could recognize but in the browser I always get the following error:

Error:
Undefined property: form_sqms_syllabus_ini::$nm_bases_access

Script: /var/www/scriptcase8/app/SQMS/form_sqms_syllabus/form_sqms_syllabus_apl.php (3394)
in_array() expects parameter 2 to be array, null given

Can anybody help me to solve this error? Sadly ScriptCase has no debugger to find the specific place in the code where this error is thrown.

I use SC-Version: 8.00.0044

My code is the following in the event onBeforeUpdate in form_sqms_syllabus:

// save changed data...
$syllabus_id					={id};
$syllabus_name					={name};
$syllabus_state_id				={sqms_state_id};
$syllabus_version				={version};
$syllabus_topic_id				={sqms_topic_id};
$syllabus_owner					={owner};
$syllabus_language_id			={sqms_language_id};
$syllabus_predecessor			={sqms_syllabus_id_predecessor};
$syllabus_successor				={sqms_syllabus_id_successor};
$syllabus_validity_period_from	={validity_period_from};
$syllabus_validity_period_to	={validity_period_to};
$syllabus_description			={description};

// increment version...
$new_version=$syllabus_version+1;

// reset data and generate new record for new data...
sc_rollback_trans();
sc_begin_trans();

sc_exec_sql("truncate mylog");
sc_exec_sql("insert into mylog values (now(),'start')");
sc_commit_trans();

$sql_ins="INSERT INTO `bpmspace_sqms`.`sqms_syllabus` VALUES (0," . 
	"'" . $syllabus_name . "'," . 
	$syllabus_state_id . "," .
	$new_version . "," .
	$syllabus_topic_id . "," .
	"'" . $syllabus_owner . "'," .
	$syllabus_language_id . "," .
	$syllabus_id . "," . 
    "0," .
    "'" . $syllabus_validity_period_from . "'," .
	"'" . $syllabus_validity_period_to   . "'," .
	"'" . $syllabus_description    		 . "')" ;

$txt = str_replace("'","''",$sql_ins);
sc_exec_sql("insert into mylog values (now(),'" . $txt . "')");
sc_commit_trans();

sc_exec_sql($sql_ins);
sc_commit_trans(); // generates the new id...

// get id of new syllabus record...

$get_new_syllabus_sql="SELECT id, name FROM bpmspace_sqms.sqms_syllabus WHERE sqms_topic_id =" . $syllabus_topic_id	. " AND sqms_syllabus_id_predecessor =" . $syllabus_id . " AND version =" . $new_version ;

$txt = str_replace("'","''",$get_new_syllabus_sql);
sc_exec_sql("insert into mylog values (now(),'" . $txt . "')");
sc_commit_trans();


sc_select(dataset, $get_new_syllabus_sql);

if (false == {dataset}) {
	sc_error_message('Error while accessing database. 1err=' . {erro});
} 
elseif ({dataset}->EOF) {
	sc_error_message('No data found!');
}
else {
	// connect new record version with previous version...
	
	$new_syllabus_id = $dataset->fields[0];
	$dataset->Close();

	$sql_upd="UPDATE bpmspace_sqms.sqms_syllabus " .
				"SET sqms_syllabus_id_successor =" . $new_syllabus_id . " " .
			  "WHERE sqms_topic_id = " . $syllabus_topic_id . " " .
			    "AND id =" . $syllabus_id . " " .
				"AND version =" . $syllabus_version ;
	
	$txt = str_replace("'","''",$sql_upd);
	sc_exec_sql("insert into mylog values (now(),'" . $txt . "')");
	sc_commit_trans();

	sc_exec_sql($sql_upd);
} 

sc_commit_trans(); 

// new syllabus-version successful created
// get syllabus elements of previous syllabus, duplicate and connect them to new syllabus version...

$get_syllabus_elements = "SELECT id, element_order, severity, sqms_syllabus_id, name, description, sqms_syllabus_element_id_predecessor, sqms_syllabus_element_id_successor " .
    					   "FROM sqms_syllabus_element " . 
    					  "WHERE sqms_syllabus_id = " . $syllabus_id ;

$txt = str_replace("'","''",$get_syllabus_elements);
sc_exec_sql("insert into mylog values (now(),'" . $txt . "')");
sc_commit_trans();

sc_select(ds2, $get_syllabus_elements);

if (false == {ds2}) {
	sc_error_message('Error while accessing database. 2err=' . {erro});
} elseif ({ds2}->EOF) { 
} else {
	// duplicate and connect syllabus elements to new syllabus version...
    while(!$ds2->EOF)
    {
		
		
		$syllabus_element_id = $ds2->fields[0] ;
		$sql_elem_ins = "INSERT INTO sqms_syllabus_element VALUES(0," . 
							$ds2->fields[1] . "," . $ds2->fields[2] . "," . 
							$new_syllabus_id . ",'" . $ds2->fields[4] . "','" . $ds2->fields[5] . "'," .
							$syllabus_element_id . ",0)" ;
		
		$txt = str_replace("'","''",$sql_elem_ins);
		sc_exec_sql("insert into mylog values (now(),'" . $txt . "')");
		sc_commit_trans();
		
		sc_exec_sql($sql_elem_ins);
		sc_commit_trans(); // generates the new id...
		
		// get id of new syllabus element record...
		$get_new_syllabus_element_sql = "SELECT id, element_order, severity, sqms_syllabus_id, name, description, sqms_syllabus_element_id_predecessor, sqms_syllabus_element_id_successor " .
    					       "FROM sqms_syllabus_element " . 
    					      "WHERE sqms_syllabus_id = " . $new_syllabus_id . " " .
			                    "AND sqms_syllabus_element_id_predecessor = " . $syllabus_element_id ;
		
		$txt = str_replace("'","''",$get_new_syllabus_element_sql);
		sc_exec_sql("insert into mylog values (now(),'" . $txt . "')");
		sc_commit_trans();
		
		sc_select(ds3, $get_new_syllabus_element_sql);

		if (false == {ds3}) {
			sc_error_message('Error while accessing database. 3err=' . {erro});
		} elseif ({ds3}->EOF) {
			sc_error_message('No data found!');
		} else {
			// connect new element record version with previous element version...

			$new_syllabus_element_id = $ds3->fields[0];
			$ds3->Close();

			$sql_elem_upd="UPDATE sqms_syllabus_element " .
						     "SET sqms_syllabus_element_id_successor =" . $new_syllabus_element_id . " " .
					       "WHERE id = " . $syllabus_element_id ;
			
			$txt = str_replace("'","''",$sql_elem_upd);
			sc_exec_sql("insert into mylog values (now(),'" . $txt . "')");
			sc_commit_trans();

			sc_exec_sql($sql_elem_upd);
			sc_commit_trans(); 			
			
			// get questions of previous syllabus element and connect them to new syllabus element...
			
			$get_syllabus_element_questions="SELECT eq.id, eq.sqms_question_id, eq.sqms_syllabus_element_id " . 
  											  "FROM sqms_syllabus_element_question eq, " .
       											   "sqms_syllabus_element e " .
   											 "WHERE e.sqms_syllabus_id = " . $syllabus_id . " " .
   											   "AND e.id = " . $syllabus_element_id . " " .
   											   "AND eq.sqms_syllabus_element_id = e.id " ;
			
			$txt = str_replace("'","''",$get_syllabus_element_questions);
			sc_exec_sql("insert into mylog values (now(),'" . $txt . "')");
			sc_commit_trans();
						
			sc_select(ds4, $get_syllabus_element_questions);

			if (false == {ds4}) {
				sc_error_message('Error while accessing database. 4err=' . {erro});
			} elseif ({ds4}->EOF) { 
			} else {
				// connect syllabus questions to new syllabus elements...
				
				while(!$ds4->EOF)
				{
					$syllabus_element_question_id = $ds4->fields[1] ;					
					
					$sql_element_question_ins = "INSERT INTO sqms_syllabus_element_question VALUES (0," . 
										$syllabus_element_question_id . "," . $new_syllabus_element_id . ")" ;

					$txt = str_replace("'","''",$sql_element_question_ins);
					sc_exec_sql("insert into mylog values (now(),'" . $txt . "')");
					sc_commit_trans();
					
					sc_exec_sql($sql_element_question_ins);
					sc_commit_trans();

					$ds4->MoveNext();
				}				
				$ds4->Close();
			}
		} 				
		$ds2->MoveNext();
    }
    $ds2->Close();
}

sc_exec_sql("insert into mylog values (now(),'ende')");
sc_commit_trans();


I already found a similar topic ( https://www.scriptcase.com.br/forum/index.php?topic=9975.0 ) but there is no real answer how to solve the problem…

I guess you need to show the generated code, specially around line 3394 (say 10 lines before and 10 lines after…)

I got an alternative solution by placing the following command before sc_begin_trans() command
$this->Ini->nm_bases_access = array(“teste”);

So try this:
$this->Ini->nm_bases_access = array(“teste”);
sc_begin_trans();

ok thats the part of the generated form_sqms_syllabus_apl.php with the regarding line:


...

function nm_acessa_banco() 
   { 
      global  $nm_form_submit, $teste_validade, $sc_where;
 
      $NM_val_null = array();
      $NM_val_form = array();
      $this->sc_erro_insert = "";
      $this->sc_erro_update = "";
      $this->sc_erro_delete = "";
      $this->SC_log_atv = false;
      if ("alterar" == $this->nmgp_opcao || "excluir" == $this->nmgp_opcao)
      {
          $this->NM_gera_log_key($this->nmgp_opcao);
      }
      if ("alterar" == $this->nmgp_opcao || "excluir" == $this->nmgp_opcao)
      {
          $this->NM_gera_log_old();
      }
      if (!empty($this->sc_force_zero))
      {
          foreach ($this->sc_force_zero as $i_force_zero => $sc_force_zero_field)
          {
              eval('if ($this->' . $sc_force_zero_field . ' == 0) {$this->' . $sc_force_zero_field . ' = "";}');
          }
      }
      $this->sc_force_zero = array();
    if ("alterar" == $this->nmgp_opcao) {
      $this->sc_evento = $this->nmgp_opcao;
      $_SESSION['scriptcase']['form_sqms_syllabus']['contr_erro'] = 'on';
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    $original_description = $this->description;
    $original_id = $this->id;
    $original_name = $this->name;
    $original_owner = $this->owner;
    $original_sqms_language_id = $this->sqms_language_id;
    $original_sqms_state_id = $this->sqms_state_id;
    $original_sqms_syllabus_id_predecessor = $this->sqms_syllabus_id_predecessor;
    $original_sqms_syllabus_id_successor = $this->sqms_syllabus_id_successor;
    $original_sqms_topic_id = $this->sqms_topic_id;
    $original_validity_period_from = $this->validity_period_from;
    $original_validity_period_to = $this->validity_period_to;
    $original_version = $this->version;
}
 
$syllabus_id					=$this->id ;
$syllabus_name					=$this->name ;
$syllabus_state_id				=$this->sqms_state_id ;
$syllabus_version				=$this->version ;
$syllabus_topic_id				=$this->sqms_topic_id ;
$syllabus_owner					=$this->owner ;
$syllabus_language_id			=$this->sqms_language_id ;
$syllabus_predecessor			=$this->sqms_syllabus_id_predecessor ;
$syllabus_successor				=$this->sqms_syllabus_id_successor ;
$syllabus_validity_period_from	=$this->validity_period_from ;
$syllabus_validity_period_to	=$this->validity_period_to ;
$syllabus_description			=$this->description ;


$new_version=$syllabus_version+1;


if ($this->Ini->sc_tem_trans_banco)
{
    $this->Db->RollbackTrans();
    $this->Ini->sc_tem_trans_banco = false;
}

if (!in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access) && !$this->Ini->sc_tem_trans_banco) /* line 3394 */
{
    $this->Db->BeginTrans();
    $this->Ini->sc_tem_trans_banco = true;
}



     $nm_select ="truncate mylog"; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                form_sqms_syllabus_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      ;

...


Hello,

Please, send this application and tables used for we check better your problem.
send to email bugs@netmake.net


best regard,
Netmake team