personally I don't care what select you guys feel the need to call, so
long as the dbi call is correct, rather it doesn't matter though because
selectrow_array() simply calls prepare() execute() any ways. 

I'd normally use LAST_INSERT_ID() my self (only if i had to) other wise
find a better way to design my database or use a database that support
foreign keys with native sanity checking.

cheers.


ryc wrote:
> 
> > >heh, my ($id) = $dbh->selectrow_array("SELECT MAX(id) FROM tbl;");
> >
> > You're in for a VERY nasty surprise as soon as two of these happen to
> > run in parallel.
> 
> I agree, you may get another insert before that select occurs and end up
> getting the wrong id. You should use "SELECT LAST_INSERTID()" or whatever
> the function name is.. that may be right but I dont remember.
> 
> Two things you might want to try... first download and install the newest
> Msql-Mysql DBD drivers.. check what the documentation says in there.. and
> second, keep changing what variable you are trying to access and maybe you
> will find one works that isnt documented.
> 
> ryan
> 
> >
> > Our code uses $sth->{mysql_insertid}. We don't have any 3.22 servers,
> > though -- they can't do (some? I forget) binary operations in a
> > SELECT right, and our customers _do_ have some reasonable
> > expectations about SQL compatibility.
> >
> > --
> > Matthias Urlichs
> >
> > ---------------------------------------------------------------------
> > Before posting, please check:
> >    http://www.mysql.com/manual.php   (the manual)
> >    http://lists.mysql.com/           (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail <[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to