-
Notifications
You must be signed in to change notification settings - Fork 819
Open
Labels
Extension: pdoAll PDO related doc issuesAll PDO related doc issues
Description
Description
SQL to create max_id table:
CREATE TABLE `max_id` (
`id` int NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2147483647 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
The following code:
<?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
lubobill1990
Metadata
Metadata
Assignees
Labels
Extension: pdoAll PDO related doc issuesAll PDO related doc issues