Hi Abu,
How can I update a specific record that has two primary keys?
when i update a record that has two primary keys and save the record, i look at the table and all the records that have the same key have changed. does not honor the two primary keys.
$g[“on_update”] = array(“update_data”, null, true);
$grid->set_events($g);
function update_data($data)
{
global $grid,$cid;
$codigo_producto = $data[“codigo_producto”];
$stock_minimo = $data[“params”][“stock_minimo”];
$stock_maximo = $data[“params”][“stock_maximo”];
$reposicion = $data[“params”][“reposicion”];
$valorcosto = $data[“params”][“valorcosto”];
$cantidad = $data[“params”][“cantidad”];
$Sql = “UPDATE octmp SET cantidad=$cantidad,stock_minimo=$stock_minimo,stock_maximo=$stock_maximo,reposicion=$reposicion,valorcosto=$valorcosto where n_ordencompra = $cid AND codigo_producto = ‘$codigo_producto'”;
$result = $grid->execute_query($Sql);
}
1. I create two different orders
(sent you email the image)
2. I change one order number 3305
(sent you email the image)
3. I look the table and were changed two different records. (It were about orders 3305 and 3306)
(sent you email the image)
Could do you help me?
Thank you
To debug the callback function, You can put:
function update_data($data)
{
phpgrid_error($data);
…
}
This will show what keys and data are there in $data var. It will help in debug.
You can also debug SQL query before executing same way.
Second, If your complete update logic is inside this callback and you wish to skip the default grid implementation of update, You should set:
$g[“on_update”] = array(“update_data”, null, false);
$grid->set_events($g);