Hello all,
I am trying to change existing connections during event onAfterInsert using the sc_exec_sql. Example:
If {myfield} = value ‘1’ then $connection = “databse1”
If {myfield} = value ‘2’ then $connection = “databse2”
If {myfield} = value ‘3’ then $connection = “databse3”
Used in event as follows.
/**
- Update a record on another table
*/
// SQL statement parameters
$update_table = ‘recording_log’; // Table name
$update_where = “recording_id = ‘{recording_id}’”; // Where clause
$update_fields = array( // Field list, add as many as needed
“audited = ‘Y’”,
);
// Update record
$update_sql = ‘UPDATE ’ . $update_table
. ’ SET ’ . implode(’, ‘, $update_fields)
. ’ WHERE ’ . $update_where;
sc_exec_sql($update_sql, $connection);
sc_commit_trans();
sc_redir(grid_audit1.php,’’,’_self’);