Re: How do i find MySQL inserted primary key?

From: Date: Sun, 18 Feb 2001 12:20:21 +0000
Subject: Re: How do i find MySQL inserted primary key?
References: 1 2 3 4  Groups: php.db 
Request: Send a blank email to php-db+get-6726@lists.php.net to get a copy of this message
Hi, You can use the LAST_INSERT_ID() function to find out the page_id for the inserted row. $query="select LAST_INSERT_ID() as page_id "; HTH Sorin Ifrim ----- Original Message ----- From: phobo <antiphobo@paradise.net.nz> To: <php-db@lists.php.net> Sent: Sunday, February 18, 2001 2:14 PM Subject: [PHP-DB] How do i find MySQL inserted primary key? > if i do an insert statement where i let MySQL assign the (autoincrementing) > primarykey, how do i find out the primary key of the record i just inserted? > > siggy > > ----- Original Message ----- > From: "Thies C. Arntzen" <thies@thieso.net> > To: "Brian Lalor" <blalor@hcirisc.cs.binghamton.edu> > Cc: <php-db@lists.php.net> > Sent: Monday, February 19, 2001 1:02 AM > Subject: Re: [PHP-DB] OCI8 error problems > > > > On Thu, Feb 15, 2001 at 10:07:23AM -0500, Brian Lalor wrote: > > > On Thu, 15 Feb 2001, Thies C. Arntzen wrote: > > > > > > > how should it? > > > > > > > > you would have to pass in the correct statement|connection > > > > handle - elsewise it simply won't work! > > > > > > Ok, that was a cobbled-up code snippet; replace $this->conn with $conn, > > > and $statement with $s. > > > > > > It still doesn't work... > > > > <? > > $db = ocilogon('tc','tc'); > > $stmt = ociparse($db,"insert into uni values (1)"); > > $success = @ociexecute($stmt); > > if (! $success) { > > var_dump(ocierror($stmt)); > > } > > ?> > > > > works for me. > > > > tc > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > For additional commands, e-mail: php-db-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#6726) next »