9 messages in com.mysql.lists.mysqlRE: last_inserted_id| From | Sent On | Attachments |
|---|---|---|
| Monika Plawna | 12 Apr 2000 11:07 | |
| Matt Levine | 12 Apr 2000 11:22 | |
| Monika Plawna | 12 Apr 2000 11:47 | |
| Robert Goff | 12 Apr 2000 12:07 | |
| Sam Mefford | 12 Apr 2000 12:19 | |
| Monika Plawna | 12 Apr 2000 12:35 | |
| Monika Plawna | 12 Apr 2000 13:22 | |
| Thimble Smith | 13 Apr 2000 02:20 | |
| Monika Plawna | 13 Apr 2000 09:56 |
| Subject: | RE: last_inserted_id![]() |
|---|---|
| From: | Robert Goff (rob...@goff.com) |
| Date: | 04/12/2000 12:07:19 PM |
| List: | com.mysql.lists.mysql |
- my $req_id = $dbh ->do ('select last_insert_id()'); - - right after I perform an insert. I check the tables manually and the - entries get inserted properly, but the above statement always returns 1.
You're getting the status of the operation, not the value of the statement. 'do' doesn't return a value, just a status. You'll have to go through the prepare, execute, fetch sequence if you want to use the select statement.
Or you could use the db handle attribute: The DBD::mysql driver supports the following attributes of database handles (read only):
$infoString = $dbh->{'info'}; $threadId = $dbh->{'thread_id'}; $insertId = $dbh->{'mysql_insertid'}
These correspond to mysql_info(), mysql_thread_id() and mysql_insertid(), respectively.
-- Only in America do we leave cars worth thousands of dollars in the driveway and put our useless junk in the garage. =============================================== Robert Goff bea...@avalon.albuquerque.nm.us Technical Writer/Editor, Webmaster 505-564-8959




