-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX GH-11587 PHP8.1: Fixed the condition for result set values to be of native type, making it compatible with previous versions. #11622
New issue
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
Closed
SakiTakamachi
wants to merge
7
commits into
php:PHP-8.1
from
SakiTakamachi:fix/result-sets-when-stringify-to-8.1
Closed
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4f4f62f
Fixed the condition that the MYSQLND_OPT_INT_AND_FLOAT_NATIVE becomes…
SakiTakamachi 970fc9f
Restored accidentally deleted parts.
SakiTakamachi 2f637d9
add test gh-11587.phpt
SakiTakamachi 3b3736d
fix syntax error
SakiTakamachi cd61def
fix "return false" to "PDO_DBG_RETURN"
SakiTakamachi 4bd7203
fix expected and skipif
SakiTakamachi a16121c
fix skipif
SakiTakamachi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,149 @@ | ||
--TEST-- | ||
GH-11587 PHP8.1: Fixed the condition for result set values to be of native type, making it compatible with previous versions. #11622 | ||
--EXTENSIONS-- | ||
pdo_mysql | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('mysqli') || !extension_loaded('mysqlnd')) { | ||
/* Need connection to detect library version */ | ||
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->exec('DROP TABLE IF EXISTS test'); | ||
|
||
$createTestTable = <<<SQL | ||
CREATE TABLE test( | ||
id INT, | ||
`float_col` FLOAT(3,2) DEFAULT NULL, | ||
`double_col` DOUBLE(3,2) DEFAULT NULL, | ||
`decimal_col` DECIMAL(3,2) DEFAULT NULL | ||
) | ||
SQL; | ||
|
||
$db->exec($createTestTable); | ||
|
||
$insertTestTable = <<<SQL | ||
INSERT INTO test(id, float_col, double_col, decimal_col) VALUES(1, 2.60, 3.60, 4.60) | ||
SQL; | ||
|
||
$db->exec($insertTestTable); | ||
|
||
// PDO::ATTR_EMULATE_PREPARES = true, PDO::ATTR_STRINGIFY_FETCHES = true | ||
Girgias marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); | ||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); | ||
$results = $db->query('SELECT * FROM test'); | ||
foreach ($results as $result) { | ||
var_dump($result); | ||
} | ||
|
||
// PDO::ATTR_EMULATE_PREPARES = true, PDO::ATTR_STRINGIFY_FETCHES = false | ||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); | ||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); | ||
$results = $db->query('SELECT * FROM test'); | ||
foreach ($results as $result) { | ||
var_dump($result); | ||
} | ||
|
||
// PDO::ATTR_EMULATE_PREPARES = false, PDO::ATTR_STRINGIFY_FETCHES = true | ||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); | ||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); | ||
$results = $db->query('SELECT * FROM test'); | ||
foreach ($results as $result) { | ||
var_dump($result); | ||
} | ||
|
||
// PDO::ATTR_EMULATE_PREPARES = false, PDO::ATTR_STRINGIFY_FETCHES = false | ||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); | ||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); | ||
$results = $db->query('SELECT * FROM test'); | ||
foreach ($results as $result) { | ||
var_dump($result); | ||
} | ||
|
||
echo 'done!'; | ||
?> | ||
--CLEAN-- | ||
<?php | ||
require __DIR__ . '/mysql_pdo_test.inc'; | ||
MySQLPDOTest::dropTestTable(); | ||
?> | ||
--EXPECT-- | ||
array(8) { | ||
["id"]=> | ||
string(1) "1" | ||
[0]=> | ||
string(1) "1" | ||
["float_col"]=> | ||
string(4) "2.60" | ||
[1]=> | ||
string(4) "2.60" | ||
["double_col"]=> | ||
string(4) "3.60" | ||
[2]=> | ||
string(4) "3.60" | ||
["decimal_col"]=> | ||
string(4) "4.60" | ||
[3]=> | ||
string(4) "4.60" | ||
} | ||
array(8) { | ||
["id"]=> | ||
int(1) | ||
[0]=> | ||
int(1) | ||
["float_col"]=> | ||
float(2.6) | ||
[1]=> | ||
float(2.6) | ||
["double_col"]=> | ||
float(3.6) | ||
[2]=> | ||
float(3.6) | ||
["decimal_col"]=> | ||
string(4) "4.60" | ||
[3]=> | ||
string(4) "4.60" | ||
} | ||
array(8) { | ||
["id"]=> | ||
string(1) "1" | ||
[0]=> | ||
string(1) "1" | ||
["float_col"]=> | ||
string(3) "2.6" | ||
[1]=> | ||
string(3) "2.6" | ||
["double_col"]=> | ||
string(3) "3.6" | ||
[2]=> | ||
string(3) "3.6" | ||
["decimal_col"]=> | ||
string(4) "4.60" | ||
[3]=> | ||
string(4) "4.60" | ||
} | ||
array(8) { | ||
["id"]=> | ||
int(1) | ||
[0]=> | ||
int(1) | ||
["float_col"]=> | ||
float(2.6) | ||
[1]=> | ||
float(2.6) | ||
["double_col"]=> | ||
float(3.6) | ||
[2]=> | ||
float(3.6) | ||
["decimal_col"]=> | ||
string(4) "4.60" | ||
[3]=> | ||
string(4) "4.60" | ||
} | ||
done! |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.