php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33618 PDO LastInsertId() returns "%ld"
Submitted: 2005-07-08 18:31 UTC Modified: 2005-07-11 14:00 UTC
From: matthew_peters at uk dot ibm dot com Assigned:
Status: Closed Package: PDO related
PHP Version: 5.1.0b2 OS: WinXP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: matthew_peters at uk dot ibm dot com
New email:
PHP Version: OS:

 

 [2005-07-08 18:31 UTC] matthew_peters at uk dot ibm dot com
Description:
------------
Call to PDO LastInsertId() with the MySQL driver was working fine for me on 5.0.3 and 5.0.4 but is returning "%ld" with 5.1 b2. I am using just the php_pdo_mysql.dll extension that came with the 5.1 beta. 


Reproduce code:
---------------
<?php

$dbh = new PDO("mysql:dbname=COMPANYDB;host=localhost",'root','*******');

$stmt = 'INSERT INTO company (name) VALUES ("Acme");';
$pdo_stmt = $dbh->prepare($stmt);
$rows_affected = $pdo_stmt->execute();
$last_insert_id = $dbh->lastInsertId();
echo $last_insert_id; // gets %ld

?>

Expected result:
----------------
What I want to see is the primary key of the row I have just inserted. The database definition by the way is:

create table company (
   id integer auto_increment,
   name char(20),
   employee_of_the_month integer,
   primary key(id) ); 

Actual result:
--------------
What I do see is %ld.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-08 18:36 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-07-08 19:02 UTC] matthew_peters at uk dot ibm dot com
Just tried this with the latest from the snapshot that iliaa  points to and got the same result. 

For the sceptical:
1. Downloaded latest (reports PHP 5.1.0-dev (cli) (built: Jul  8 2005 12:23:17)
2. enabled php.ini-dist as php.ini
3. made the extension_dir c:\php\ext
4. added the one extension php_pdo_mysql
5. ran my test program - output "%ld".
 [2005-07-08 21:27 UTC] wez@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Will be fixed in the next snapshot.
 [2005-07-11 14:00 UTC] matthew_peters at uk dot ibm dot com
I concur - fixed in the latest build. Many thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 19:01:30 2024 UTC