-
-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Description
In a specific table field structure, and simple query will get this error:
Amp\Sql\SqlException: Unexpected string length for datetime in binary protocol: 8 in /vendor/amphp/mysql/src/MysqlDataType.php:190Test table SQL Dump:
CREATE TABLE `users_copy1` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`area_code` mediumint unsigned NOT NULL DEFAULT '0',
`last_active_ip` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`created_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `created_at` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `users_copy1` (`id`, `area_code`, `last_active_ip`, `created_at`) VALUES
(2, 0, '10.0.0.1', '2025-06-12 18:13:22');Reproduce code:
$config = \Amp\Mysql\MysqlConfig::fromString(
"host=192.168.4.2 user=test password= db=test"
);
$pool = new \Amp\Mysql\MysqlConnectionPool($config);
$statement = $pool->prepare("select * from users_copy1 where id=2");
$result = $statement->execute();
foreach ($result as $row) {
print_r($row);
}If we delete field area_code, or delete field last_active_ip, or change area_code from type mediumint to int, the problem will gone.
MySQL: 5.7.44, 8.0.41
PHP: 8.2.28 in Docker from php:8.2.28-fpm-bookworm
amphp/mysql: 3.0.0
amphp/sql: 2.0.1
amphp/sql-common: 2.0.3
Metadata
Metadata
Assignees
Labels
No labels