#33618 [Opn->Csd]: PDO LastInsertId() returns "%ld"
| From: | wez@php.net | Date: | Fri, 08 Jul 2005 19:27:02 +0000 |
| Subject: | #33618 [Opn->Csd]: PDO LastInsertId() returns "%ld" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-81598@lists.php.net to get a copy of this message | ||
ID: 33618
Updated by: wez@php.net
Reported By: matthew_peters at uk dot ibm dot com
-Status: Open
+Status: Closed
Bug Type: PDO related
Operating System: WinXP
PHP Version: 5.1.0b2
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2005-07-08 19:02:26] 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 18:36:40] 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 18:31:22] 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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33618&edit=1