heh, my ($id) = $dbh->selectrow_array("SELECT MAX(id) FROM tbl;");

xris wrote:
> 
> > Woops sorry about that last message.
> > Try using the following:
> > my $id = $sth->{insertid};
> > That is what I had to change it to, to get it working.. despite what the
> > documentation says.
> 
> Actually, I can't use that.  The script dies, it's not like it just warns me
> that it doesn't work, but it actually stops executing when it reaches that
> statement.
> 
> I just do something like:
> 
> $id = $sh->{mysql_insertid};
> $sh->finish;
> if ($id < 1) {
>     $sh = $dbh->prepare('SELECT MAX(id) FROM myTable');
>     ...
>     ($id) = $sh->fetchrow;
>     ...
> }
> 
> It just seems a little silly to have to do this.
> 
> -Chris
> 
> > GL.
> >
> > ryan
> >
> >>> My ISP recently updated one of their servers to 3.23.38, and all of a
> >> sudden
> >>> a BUNCH of my code stopped working.   I use a number of insert queries
> >> (new
> >>> items, new search caches, etc), where I insert a blank record, and then
> >> take
> >>> notes of its id (usually "int unsigned auto_increment primary key"), to
> > be
> >>> used in a subsequent UPDATE statement (or INSERT, to a related table).
> >>>
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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