P is for Practical | |
PerlMonks |
Re: Getting null value from last_insert_id()by ferreira (Chaplain) |
on Apr 05, 2007 at 11:09 UTC ( [id://608447]=note: print w/replies, xml ) | Need Help?? |
If that:
looks like your actual code, you have some problems to work out before getting something from last_insert_id(). First, DBI drivers don't expect ';' ending the statements most of the time (even though I don't know especifically about mysql). I would suggest to remove this terminator. Second, if you are not using RaiseError => 1, every problem/error is passing unnoticed if you don't check the return of DBI methods like prepare, execute and finish. One of the easiest ways is to add RaiseError => 1 to your connection creation and let DBI throw an exception if something goes wrong. After getting rid of these issues, you may try with more confidence to interpret the results of last_insert_id() (and it is possible it just works then and does not need more tweaks). Also consider Re: Getting null value from last_insert_id() and make sure you need last_insert_id after all.
In Section
Seekers of Perl Wisdom
|
|