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…