Annotation of embedaddon/php/ext/pdo_mysql/tests/pdo_mysql_attr_oracle_nulls.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: PDO::ATTR_ORACLE_NULLS
3: --SKIPIF--
4: <?php
5: require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
6: require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7: MySQLPDOTest::skip();
8: ?>
9: --FILE--
10: <?php
11: require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
12: $db = MySQLPDOTest::factory();
13: MySQLPDOTest::createTestTable($db);
14:
15: $tmp = array();
16: if (false !== @$db->setAttribute(PDO::ATTR_ORACLE_NULLS, $tmp))
17: printf("[001] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...\n");
18:
19: $tmp = new stdClass();
20: if (false !== @$db->setAttribute(PDO::ATTR_ORACLE_NULLS, $tmp));
21: printf("[002] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...\n");
22:
23: if (false !== @$db->setAttribute(PDO::ATTR_ORACLE_NULLS, 'pdo'))
24: printf("[003] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...\n");
25:
26: $db->setAttribute(PDO::ATTR_ORACLE_NULLS, 1);
27: $stmt = $db->query("SELECT NULL AS z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, '" . chr(0) . " e' AS e");
28: var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
29:
30: $db->setAttribute(PDO::ATTR_ORACLE_NULLS, 0);
31: $stmt = $db->query("SELECT NULL AS z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, '" . chr(0) . " e' AS e");
32: var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
33:
34: $db->setAttribute(PDO::ATTR_ORACLE_NULLS, 1);
35: $stmt = $db->query('SELECT VERSION() as _version');
36: $row = $stmt->fetch(PDO::FETCH_ASSOC);
37: if ((int)substr($row['_version'], 0, 1) >= 5)
38: $have_procedures = true;
39: else
40: $have_procedures = false;
41:
42: $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
43: $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
44:
45: if ($have_procedures && (false !== $db->exec('DROP PROCEDURE IF EXISTS p')) &&
46: (false !== $db->exec("CREATE PROCEDURE p() BEGIN SELECT NULL as z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, ' e' AS e; END;"))) {
47: // requires MySQL 5+
48: $stmt = $db->prepare('CALL p()');
49: $stmt->execute();
50: $expected = array(
51: array(
52: "z" => NULL,
53: "a" => NULL,
54: "b" => " ",
55: "c" => NULL,
56: "d" => " d",
57: "e" => " e",
58: ),
59: );
60: do {
61: $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC);
62: if ($tmp != $expected) {
63: printf("[004] Expecting %s got %s\n",
64: var_export($expected, true), var_export($tmp, true));
65: }
66: } while ($stmt->nextRowset());
67:
68: $stmt->execute();
69: do {
70: $tmp = $stmt->fetchAll(PDO::FETCH_ASSOC);
71: if ($tmp != $expected) {
72: printf("[005] Expecting %s got %s\n",
73: var_export($expected, true), var_export($tmp, true));
74: }
75: } while ($stmt->nextRowset());
76:
77: }
78:
79: if ($have_procedures)
80: @$db->exec('DROP PROCEDURE IF EXISTS p');
81:
82: print "done!";
83: ?>
84: --EXPECTF--
85: [002] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...
86: [003] Maybe PDO could indicate that this is not a proper way of setting ATTR_ORACLE_NULLS...
87: array(1) {
88: [0]=>
89: array(6) {
90: [%u|b%"z"]=>
91: NULL
92: [%u|b%"a"]=>
93: NULL
94: [%u|b%"b"]=>
95: %unicode|string%(1) " "
96: [%u|b%"c"]=>
97: NULL
98: [%u|b%"d"]=>
99: %unicode|string%(2) " d"
100: [%u|b%"e"]=>
101: %unicode|string%(3) "%se"
102: }
103: }
104: array(1) {
105: [0]=>
106: array(6) {
107: [%u|b%"z"]=>
108: NULL
109: [%u|b%"a"]=>
110: %unicode|string%(0) ""
111: [%u|b%"b"]=>
112: %unicode|string%(1) " "
113: [%u|b%"c"]=>
114: %unicode|string%(0) ""
115: [%u|b%"d"]=>
116: %unicode|string%(2) " d"
117: [%u|b%"e"]=>
118: %unicode|string%(3) "%se"
119: }
120: }
121: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>