2009年8月13日星期四

Re: [fw-db] Zend_Db last_insert_id returns super big number

I am not sure I can confirm this. Can you reproduce without Zend_Db?
Perhaps its a PHP or mysqli problem?

My test case looked alot like this:

$db = Zend_Db::factory('Mysqli', array('username' => 'developer',
'dbname' => 'test', 'password' => 'developer'));

/**
* CREATE TABLE `test`.`testbigint` (
* `id` BIGINT( 64 ) NOT NULL AUTO_INCREMENT ,
* `name` VARCHAR( 50 ) NOT NULL ,
* PRIMARY KEY ( `id` )
* ) ENGINE = MYISAM
*/

$x = $db->insert('testbigint', array('name' => 'Ralph'));
$i = $db->lastInsertId();
var_dump($i);


See if you can dig deeper, I am simply not able to reproduce.

-ralph

Beier wrote:
> I have a MySql table whose primary key is a 64bit BigInt type
>
> I'm using Zend_Db to insert a new row, then call lastInsertId() to retreive
> the new row's id, what I get back is a super large number such as
> 18446744072633694008, and this number changes from time to time, but always
> this large. the auto increment index is set to 0, and in the database the
> record actually got inserted with correct primary id, (0, 1, 2...), it's
> just that the id return from lastInsertId() gives weird number. Is it a
> known issue for Zend_db, which doesn't deal with 64 bit number?
>
> environment:
> Zend Framework 1.8.4
> Apache2 on 32bit box, Ubuntu OS
> MySQL5.1
> PHP5.2.4
> MySQL adapter: mysqli
>
>
> Thanks
>

没有评论: