Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Thread safe way to get auto incremented primary key inserted into another table (so they can be joined later)
- $result = mysql_query("SHOW TABLE STATUS LIKE 'table_name'");
- $row = mysql_fetch_array($result);
- $nextId = $row['Auto_increment'];
- mysql_free_result($result);
- $sql = mysql_query("INSERT the information you want in the main table")
- START TRANSACTION;
- INSERT INTO files (file_id, url) VALUES (NULL, 'text.doc');
- INSERT INTO grades (file_id, grade) VALUES (LAST_INSERT_ID(), 'some-grade');
- COMMIT;
Add Comment
Please, Sign In to add comment