there is a request to the database to add rows

INSERT INTO table1 (cal1, cal2) VALUES ('$val1', '$val2') 

In the same table there is an id field which is filled in by autoincrement.

The bottom line is that the next request for adding to another table should also record the newly created id , but I cannot catch it ..

nor so:

  $query = "INSERT INTO table2 (version, id) VALUES ('$version1', 'SELECT MAX(`id`) FROM `table1`)'"; TestsDb::query($query); 

nor so:

 $idA = mysqli_insert_id(); 

In this case, it sends 0, allegedly does not see the work with autoincrement.

  • According to the documentation, it’s not a question of the AUTO_INCREMENT attribute. perhaps there is really no auto increment. SELECT MAX (id) is a bad attempt to get an id. - KoVadim
  • I know it was from despair) - Mihail2342
  • resolved the issue INSERT INTO TABLE (cal1, cal2) VALUES ('$ val1', '$ val2') RETURNING * by this approach - Mikhail2342

0