>
> on ma, 10 feb 2003 19:04:01 GMT, Mario Kulka wrote:
>
> > $sth = $dbh->prepare ("SELECT LAST_INSERT_ID() FROM
> $table"); $sth ->
> > execute(); $ad_id = $sth->fetchrow_array();
> > $sth->finish();
> > ...
> >
> > The above works fine and gives me the last id, but what
> worries me is
> > the possibility of someone submitting new record between the lines
> > "Insert record" and the rest. Is that a valid concern?
>
> You don't have to worry about this, because the result of the
> LAST_INSERT_ID() function is maintained by the server on a
> per-connection
> basis.
>
> You do have to worry about your 'SELECT LAST_INSERT_ID() FROM atable'
> syntax though, which does not return what you expect. In
> fact, it returns
> as many rows as there are in atable, each containing the value of the
> auto_increment field generated in the last INSERT statement,
> regardless
> which table the INSERT statement whas issued for.
Interesting, so should one do $query = 'SELECT LAST_INSERT_ID()';
To get the actual ID of the insert you just did instead of
$query = 'SELECT LAST_INSERT_ID() FROM joemama;
Thanks!
>
> --
> felix
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]