[php-src] Issue #9811: PDO::lastInsertId returns 18446744073709551615 instead of -1

From: Date: Sat, 22 Oct 2022 15:25:04 +0000
Subject: [php-src] Issue #9811: PDO::lastInsertId returns 18446744073709551615 instead of -1
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242664@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9811 Author: mowangjuanzi ### Description The following code: ```php <?php $pdo = new PDO("mysql:dbname=test;host=127.0.0.1", 'root', 'password'); $stmt = $pdo->prepare("INSERT INTO max_id (id, title) VALUES(?, ?)"); var_dump($stmt->execute([-1, "C"])); ``` Resulted in this output: ``` "18446744073709551615" ``` But I expected this output instead: ``` "-1" ``` I found that the problem may be in https://github.com/php/php-src/blob/master/ext/pdo_mysql/mysql_driver.c#L296 zend_u64_to_str does not recognize negative IDs. ### PHP Version 8.1.11 ### Operating System Ubuntu 22.04

« previous php.bugs (#242664) next »