-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle column count change in PDO MySQL
This has been fixed for PDO SQlite by GH-4313, however the same issue also applied to PDO MySQL. Move the column count setting function into the main PDO layer (and export it) and then use it in both PDO SQLite and PDO MySQL.
- Loading branch information
Showing
5 changed files
with
108 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--TEST-- | ||
Change column count after statement has been prepared | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded'); | ||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc'); | ||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); | ||
MySQLPDOTest::skip(); | ||
?> | ||
--FILE-- | ||
<?php | ||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); | ||
|
||
$db = MySQLPDOTest::factory(); | ||
$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); | ||
|
||
$db->exec('DROP TABLE IF EXISTS test'); | ||
$db->exec('CREATE TABLE test (id INTEGER PRIMARY KEY NOT NULL, name VARCHAR(255) NOT NULL)'); | ||
|
||
$stmt = $db->prepare('INSERT INTO test (id, name) VALUES(:id, :name)'); | ||
$stmt->execute([ | ||
'id' => 10, | ||
'name' => 'test', | ||
]); | ||
|
||
$stmt = $db->prepare('SELECT * FROM test WHERE id = :id'); | ||
$stmt->execute(['id' => 10]); | ||
var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC)); | ||
|
||
$db->exec('ALTER TABLE test ADD new_col VARCHAR(255)'); | ||
$stmt->execute(['id' => 10]); | ||
var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC)); | ||
|
||
?> | ||
--CLEAN-- | ||
<?php | ||
require __DIR__ . '/mysql_pdo_test.inc'; | ||
MySQLPDOTest::dropTestTable(); | ||
?> | ||
--EXPECT-- | ||
array(1) { | ||
[0]=> | ||
array(2) { | ||
["id"]=> | ||
string(2) "10" | ||
["name"]=> | ||
string(4) "test" | ||
} | ||
} | ||
array(1) { | ||
[0]=> | ||
array(3) { | ||
["id"]=> | ||
string(2) "10" | ||
["name"]=> | ||
string(4) "test" | ||
["new_col"]=> | ||
NULL | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters