Answer the question
In order to leave comments, you need to log in
Is it correct to use LOCK TABLES READ to preserve data integrity in this case?
A topic is created and a message is added to the topic. The parent of the message is the number of the newly created topic:
mysqli_query("LOCK TABLES `themes_table` READ;");
mysqli_query( "INSERT INTO `themes_table` ( ... ;" );
$new_theme_id = mysqli_insert_id();
mysqli_query( "INSERT INTO `posts_table` ( `parent_theme_id`=$new_theme_id, ... ;" );
mysqli_query("UNLOCK TABLES;");
Answer the question
In order to leave comments, you need to log in
insert_id will be wrong
Is mysqli_insert_id(); will return not the same id that was created in the current connection? And then the hypothetical other connection will not affect it in any way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question