clone row and it dependence table

Questionsclone row and it dependence table
pavlos nikiforidis asked 4 years ago

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.

pavlos nikiforidis replied 4 years ago

I solved the problem. the funtion is a php function i was thinking that it was js function.
$last_id = mysqli_insert_id($conn);

1 Answers
Abu Ghufran Staff answered 4 years ago

Thanks for updating.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

15 + 10 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?