Greetings all!
am having a bit of a head ace with the included update/insert sql scripts as arrays are not my strong point at all, in fact have avoided them as much as possible till now.
I have tried checking the demos for somewhere the uses the included scripts but seems that none of them actually use the inbuilt features…
Have pasted both the insert and update below, have these running on the afterinsert and afterupdate with a clause on when to shoot, both of which are not liking the variables, have tried replacing the variables with the fields {field} which also failed to insert or update, now have them with variables $projectID which also isnt working.
Some help please on how I should actually do this with an array…
// Update data in table if entry exists
$update_table = 'project_specs'; // Table name
$update_where = "projectID = '{projectID}'"; // Where clause
$update_fields = array( // Field list, add as many as needed
"projectID = '$projectID'",
"ownerID = '$ownerID'",
"langNew = '$langNew'",
);
// Update record
$update_sql = 'UPDATE ' . $update_table
. ' SET ' . implode(', ', $update_fields)
. ' WHERE ' . $update_where;
sc_exec_sql($update_sql);
// Insert data in table if doesnt exist
$insert_table = 'project_specs'; // Table name
$insert_fields = array( // Field list, add as many as needed
'projectID' => "$projectID",
'ownerID' => "$ownerID",
'langNew' => "$langNew",
);
// Insert record
$insert_sql = 'INSERT INTO ' . $insert_table
. ' (' . implode(', ', array_keys($insert_fields)) . ')'
. ' VALUES (' . implode(', ', array_values($insert_fields)) . ')';
sc_exec_sql($insert_sql);
thanks in advance!