1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
--TEST--
PDO::ATTR_ORACLE_NULLS
--EXTENSIONS--
pdo_mysql
--SKIPIF--
<?php
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
MySQLPDOTest::skip();
?>
--FILE--
<?php
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
$db = MySQLPDOTest::factory();
$procedure = 'pdo_mysql_attr_oracle_nulls_p';
try {
$db->setAttribute(PDO::ATTR_ORACLE_NULLS, []);
} catch (\TypeError $e) {
echo $e->getMessage(), \PHP_EOL;
}
try {
$db->setAttribute(PDO::ATTR_ORACLE_NULLS, new stdClass());
} catch (\TypeError $e) {
echo $e->getMessage(), \PHP_EOL;
}
try {
$db->setAttribute(PDO::ATTR_ORACLE_NULLS, 'pdo');
} catch (\TypeError $e) {
echo $e->getMessage(), \PHP_EOL;
}
$db->setAttribute(PDO::ATTR_ORACLE_NULLS, 1);
$stmt = $db->query("SELECT NULL AS z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, '" . chr(0) . " e' AS e");
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
$db->setAttribute(PDO::ATTR_ORACLE_NULLS, 0);
$stmt = $db->query("SELECT NULL AS z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, '" . chr(0) . " e' AS e");
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
$db->setAttribute(PDO::ATTR_ORACLE_NULLS, 1);
$stmt = $db->query('SELECT VERSION() as _version');
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ((int)strtok($row['_version'], '.') >= 5)
$have_procedures = true;
else
$have_procedures = false;
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
if ($have_procedures && (false !== $db->exec("DROP PROCEDURE IF EXISTS {$procedure}")) &&
(false !== $db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT NULL as z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, ' e' AS e; END;"))) {
// requires MySQL 5+
$stmt = $db->prepare("CALL {$procedure}()");
$stmt->execute();
do {
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
} while ($stmt->nextRowset());
$stmt->execute();
do {
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
} while ($stmt->nextRowset());
}
print "done!";
?>
--CLEAN--
<?php
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
$db = MySQLPDOTest::factory();
$db->exec("DROP PROCEDURE IF EXISTS pdo_mysql_attr_oracle_nulls_p");
?>
--EXPECTF--
Attribute value must be of type int for selected attribute, array given
Attribute value must be of type int for selected attribute, stdClass given
Attribute value must be of type int for selected attribute, string given
array(1) {
[0]=>
array(6) {
["z"]=>
NULL
["a"]=>
NULL
["b"]=>
string(1) " "
["c"]=>
NULL
["d"]=>
string(2) " d"
["e"]=>
string(3) "%se"
}
}
array(1) {
[0]=>
array(6) {
["z"]=>
NULL
["a"]=>
string(0) ""
["b"]=>
string(1) " "
["c"]=>
string(0) ""
["d"]=>
string(2) " d"
["e"]=>
string(3) "%se"
}
}
array(1) {
[0]=>
array(6) {
["z"]=>
NULL
["a"]=>
NULL
["b"]=>
string(1) " "
["c"]=>
NULL
["d"]=>
string(2) " d"
["e"]=>
string(2) " e"
}
}
array(0) {
}
array(1) {
[0]=>
array(6) {
["z"]=>
NULL
["a"]=>
NULL
["b"]=>
string(1) " "
["c"]=>
NULL
["d"]=>
string(2) " d"
["e"]=>
string(2) " e"
}
}
array(0) {
}
done!
|