I have my database setup totally - thats all fine and dandy.
I am creating a photogallery and now i'm creating a batch add function to add in my existing photo's - I've got almost 900.
Anyway thats kinda irrelevant. What i want to do is do multiple inserts into my database, i know how to do it fine with auto creating the id etc. However, how can i easily get the ID? I've been trying to think of the best way to do this.
So far all i can think of is:
INSERT RECORD QUERY
then
SELECT max(id) FROM tablename
or
SELECT id FROM tablename ORDER BY id DESC LIMIT 0, 1
Both should work - I'm just wondering if there is a better way to do this? Cant mySQL return the ID when doing a query? it seems like bad practice to have to do two queries each time i want to insert. With 900 pictures thats 1800 queries! I need the id as i need to take note of it elsewhere in my system - I wont bother going into explianing why.