We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The following code:
<?php declare(strict_types=1); function getPDO(): PDO { return new PDO('mysql:host=127.0.0.1;dbname=test', 'root', 'root', [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false, ]); } function testPDO(): void { $pdo = getPDO(); $pdo->exec(<<<'SQL' DROP TABLE IF EXISTS `test` SQL); $pdo->exec(<<<'SQL' CREATE TABLE `test` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`) USING BTREE, INDEX `name`(`name`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; SQL); $pdo->exec(<<<'SQL' INSERT INTO `test` (`name`) VALUES ('test1'); SQL); $pdo2 = getPDO(); $stmt = $pdo2->prepare('select * from test'); var_dump('PDO-1:', $stmt->execute(), $stmt->fetchAll()); $stmt->closeCursor(); // Optional. Segmentation fault (core dumped) $pdo->exec(<<<'SQL' ALTER TABLE `test` ADD COLUMN `a` varchar(255) NOT NULL DEFAULT ''; SQL); var_dump('PDO-2:', $stmt->execute(), $stmt->fetchAll()); } function getMysqli(): mysqli { return new mysqli('127.0.0.1', 'root', 'root', 'test'); } function testMysqli(): void { $mysqli = getMysqli(); $mysqli->query(<<<'SQL' DROP TABLE IF EXISTS `test` SQL); $mysqli->query(<<<'SQL' CREATE TABLE `test` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`) USING BTREE, INDEX `name`(`name`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; SQL); $mysqli->query(<<<'SQL' INSERT INTO `test` (`name`) VALUES ('test1'); SQL); $mysqli2 = getMysqli(); $stmt = $mysqli2->prepare('select * from test'); var_dump('mysqli-1:', $stmt->execute(), $stmt->get_result()->fetch_all()); $mysqli->query(<<<'SQL' ALTER TABLE `test` ADD COLUMN `a` varchar(255) NOT NULL DEFAULT ''; SQL); var_dump('mysqli-2:', $stmt->execute(), $stmt->get_result()->fetch_all()); } testMysqli(); testPDO();
Resulted in this output:
string(9) "mysqli-1:" bool(true) array(1) { [0]=> array(2) { [0]=> int(1) [1]=> string(5) "test1" } } string(9) "mysqli-2:" bool(true) array(0) { } string(6) "PDO-1:" bool(true) array(1) { [0]=> array(4) { ["id"]=> int(1) [0]=> int(1) ["name"]=> string(5) "test1" [1]=> string(5) "test1" } } Segmentation fault (core dumped)
But I expected this output instead:
string(9) "mysqli-1:" bool(true) array(1) { [0]=> array(2) { [0]=> int(1) [1]=> string(5) "test1" } } string(9) "mysqli-2:" bool(true) array(1) { [0]=> array(3) { [0]=> int(1) [1]=> string(5) "test1" [2]=> string(0) "" } } string(6) "PDO-1:" bool(true) array(1) { [0]=> array(4) { ["id"]=> int(1) [0]=> int(1) ["name"]=> string(5) "test1" [1]=> string(5) "test1" } } string(6) "PDO-2:" bool(true) array(1) { [0]=> array(6) { ["id"]=> int(1) [0]=> int(1) ["name"]=> string(5) "test1" [1]=> string(5) "test1" ["a"]=> string(0) "" [2]=> string(0) "" } }
This bug affects mysqli, pdo_mysql.
I will fix this issue later.
PHP 8.1.21
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
The following code:
Resulted in this output:
But I expected this output instead:
This bug affects mysqli, pdo_mysql.
I will fix this issue later.
PHP Version
PHP 8.1.21
Operating System
No response
The text was updated successfully, but these errors were encountered: