Is there a way to insert into MySQL database using PHP PDO and return its id? Or I will just have to search fot its id after insertion?
what happen if there is concurrent insertion?
Phen
2010-02-09 05:13:17
@Phen: That's another question entirely. @Chacha102 provided an excellent answer to *this* question already.
Jonathan Sampson
2010-02-09 05:14:34
You might want to check out this comment about thread-safeness: http://us2.php.net/manual/en/pdo.lastinsertid.php#84530 (Just a quick Ctrl+F search on the Docuementation for the word 'safe')
Chacha102
2010-02-09 05:14:42
+1 for being quicker on the draw, but shouldn't the d be lowercased? ;)
munch
2010-02-09 05:17:51
@much Well, All PHP functions are case-insensitive .. so.... doesn't really matter too much.
Chacha102
2010-02-09 05:19:05
@Chacha: very interesting. I guess I assumed that b/c variable names were case sensitive, functions were as well. Prob better practice to code in a case sensitive manner anyway, though
munch
2010-02-09 05:30:01
So .. it took me just a *little* less time to search the documentation? :P
Chacha102
2010-02-09 05:12:38