function custom_clone($data)
{
global $g;
$src_id = $data[“id”]; // first column name of grid
$f = $data[“params”];
$fields_str = implode(“,”,$f);
$sql = “INSERT INTO recipes(description,machine) SELECT CONCAT(description,’-clone’),machine FROM recipes WHERE id = $src_id”;
$g->execute_query($sql);
$sql=”INSERT INTO recipe_details (lookup_recipe, extr, gfp, fp, percent) SELECT “Previous_query_id”, extr, gfp, fp, percent FROM recipe_details WHERE lookup_recipe=$src_id”;
$g->execute_query($sql);
}
The question is when i clone a row on master table then i want to clone also the the rows from detail table but i need the id of the master table insert.
Thank you in advance for your help.
1 Answers
Thanks for updating.
Your Answer
I solved the problem. the funtion is a php function i was thinking that it was js function.
$last_id = mysqli_insert_id($conn);