Here is my query. Everything in it parses fine but not sure why it errors out as I don’t get an actual error code or description.
//add transaction record after update
$e[“on_after_update”] = array(“update_data”, null, true);
$g->set_events($e);
function update_data($data)
{
global$g;
$g->execute_query(“INSERTINTO transactions
(item_sak
, item_type
,transtype
,transcode
,trans_date
performed_by)
VALUES ({$data[“params”][“employee_sak”]}
, ’employee’
, ‘EMPL’
, ‘002’
, NOW()
, $_SESSION[accounts_sak]
)”);
}
Perhaps a typo: INSERTINTO should be INSERT INTO (with a space in between)
Second, instead of passing query to try execute_query function, assign the query string to a variable e.g. $q and call:
$q = “INSERT INTO …. “;
phpgrid_error($q);
This will push the whole query in error message window for you to debug.
You can also use:
error_log($q);
and see php error log file.
I think that is a paste formatting issue. It isn’t like that in the actual code.
I will try the other suggestions
But there was another sql error that I didn’t notice before thanks to your debugging code! Hopefully this fixes it
Ok so I found the actual issue that I am having. I am trying to insert employee_sak which is set to edit=false as shown below. It is also the first column in my grid. How can I get that value so I can use it in my insert on_update?
//EMPLOYEE_SAK
$col = array();
$col[“title”] = “Employee Sak”; // caption of column, can use HTML tags too
$col[“name”] = “employee_sak”; // grid column name, same as db field or alias from sql
$col[“show”] = array(“list”=>false, “add”=>false, “edit”=>false “view”=>false, “bulkedit”=>false);
$col[“editable”] = true;
$col[“hidden”] = true;
$col[“hidedlg”] = true;
$cols[] = $col;
To get primary key column in callback functions, you need to use with params, e.g.
$data["employee_sak"]