Well, I'm using PHP's Mysqli class and I came across the following situation ...
I have two tables, table A is the main one and table B is the daughter until then it is ok, what I need to do is to treat the commit and rollback to avoid failures in the future I mounted the following Script ...
$DB->mConnect(); $DB->Mysqli->autocommit(false); $er = true; $query = "insert into (descricao) values ('testes')"; $er = !$DB->Mysqli->query($query) ? false : true; $codigo = $DB->Mysqli->insert_id; $query2 = "insert into (cod_pai, descricao) values (".$codigo.", 'teste filho')"; $er = !$DB->Mysqli->query($query2) ? false : true; $er ? $DB->Mysqli->commit() : $DB->Mysqli->rollback(); var_dump($err);Now comes my doubt, the daughter table B is dependent on the auto increment code that is generated in table A, what is happening is that the way I did not generate the Code, and this way when it will use in the table B says that the code in table A does not exist.
Would you like to know what I did wrong?
Thanks for your help!