-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PDO parameter types for national character set strings
- Loading branch information
1 parent
3817cba
commit 4afce8e
Showing
11 changed files
with
221 additions
and
9 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
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,27 @@ | ||
--TEST-- | ||
PDO_DBLIB: national character set values are quoted correctly in queries | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo_dblib')) die('skip not loaded'); | ||
require dirname(__FILE__) . '/config.inc'; | ||
?> | ||
--FILE-- | ||
<?php | ||
require dirname(__FILE__) . '/config.inc'; | ||
|
||
$stmt = $db->prepare('SELECT :value'); | ||
$stmt->bindValue(':value', 'foo', PDO::PARAM_STR | PDO::PARAM_STR_NATL); | ||
$stmt->execute(); | ||
|
||
var_dump($stmt->debugDumpParams()); | ||
?> | ||
--EXPECT-- | ||
SQL: [13] SELECT :value | ||
Sent SQL: [13] SELECT N'foo' | ||
Params: 1 | ||
Key: Name: [6] :value | ||
paramno=-1 | ||
name=[6] ":value" | ||
is_param=1 | ||
param_type=1073741826 | ||
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
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,44 @@ | ||
--TEST-- | ||
PDO MySQL national character set parameters don't affect true prepared statements | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded'); | ||
require dirname(__FILE__) . '/config.inc'; | ||
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; | ||
PDOTest::skip(); | ||
?> | ||
--FILE-- | ||
<?php | ||
require dirname(__FILE__) . '/config.inc'; | ||
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; | ||
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); | ||
|
||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); | ||
|
||
$db->exec('CREATE TABLE test (bar NCHAR(4) NOT NULL)'); | ||
|
||
$stmt = $db->prepare('INSERT INTO test VALUES(?)'); | ||
$stmt->bindValue(1, 'foo', PDO::PARAM_STR | PDO::PARAM_STR_NATL); | ||
$stmt->execute(); | ||
|
||
var_dump($db->query('SELECT * from test')); | ||
foreach ($db->query('SELECT * from test') as $row) { | ||
print_r($row); | ||
} | ||
|
||
?> | ||
--CLEAN-- | ||
<?php | ||
require dirname(__FILE__) . '/mysql_pdo_test.inc'; | ||
MySQLPDOTest::dropTestTable(); | ||
?> | ||
--EXPECTF-- | ||
object(PDOStatement)#%d (1) { | ||
["queryString"]=> | ||
string(18) "SELECT * from test" | ||
} | ||
Array | ||
( | ||
[bar] => foo | ||
[0] => foo | ||
) |
Oops, something went wrong.