Hi Abu!
I would like to know how can I clone a row but I just want to insert some values of the selected row not all of them.
Example:
I have my employees table.
ID
Name
LastName
Address
City
State
I only want to copy in the new record the City and State of the row selected and leave the other columns with no information. How can I achieve this?
Thank you.
You need to use custom clone function,
e.g.
$e["on_clone"] = array("custom_clone","null",false);
$g->set_events($e); // uncomment this to enable on_clone event
function custom_clone($data)
{
$src_id = $data["id"];
$f = $data["params"];
// here you can unset the $f["address"] and other fields.
$fields_str = implode(",",$f);
$sql = "INSERT INTO invheader ($fields_str) SELECT $fields_str FROM invheader WHERE id = $src_id";
mysql_query($sql);
}
Code: http://www.phpgrid.org/demo/demos/editing/clone-row.phps