RE: [PHP-WIN] Getting the auto increment value of the row inserte d ??
| From: | Boget, Chris | Date: | Mon, 08 Jan 2001 19:26:43 +0000 |
| Subject: | RE: [PHP-WIN] Getting the auto increment value of the row inserte d ?? | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-4873@lists.php.net to get a copy of this message | ||
> I am using PHP4 and mySQL.
> I have a table in mySQL with an auto increment column as the
> primary key.
> When I do an insert from the PHP page, I need to return the inserted
> record's primary key.
> Currently after inserting the record I am immediatly doing a
> "select max(pk) from tablename" to fetch the value.
> Is there any better solution for this.
Look into:
mysql_insert_id();
Chris