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