I have 2 tables: user and photos (in a mysql db).
Here you can see the relation between the 2 tables
User Photos
----------------- -------------------------------
| id | user | | id_user | photo_url |
----------------- -------------------------------
|| /\
||______________________||
|________________________|
When I save a new user into the table "user", if the insert is done successfully, I have to take the value of the "id" field of the user just saved, and save it inside the "id_user" field of the table "photos", in order to make a relation between a user and its photos.
Making the first insert (table "user"), then getting, with a SELECT, the "id" of the last record and then again saving the user's photos it's not the right way to do it. How should i do it?