1--TEST-- 2Test PDO->quote() for PDO_OCI 3--EXTENSIONS-- 4pdo 5pdo_oci 6--SKIPIF-- 7<?php 8require(__DIR__.'/../../pdo/tests/pdo_test.inc'); 9PDOTest::skip(); 10?> 11--FILE-- 12<?php 13 14require __DIR__ . '/../../pdo/tests/pdo_test.inc'; 15$db = PDOTest::factory(); 16 17@$db->exec("drop table poq_tab"); 18$db->query("create table poq_tab (t varchar2(100))"); 19$stmt = $db->prepare('select * from poq_tab'); 20 21// The intent is that the fetched data be identical to the unquoted string. 22// Remember!: use bind variables instead of PDO->quote() 23 24$a = array("", "a", "ab", "abc", "ab'cd", "a\b\n", "'", "''", "a'", "'z", "a''b", '"'); 25foreach ($a as $u) { 26 $q = $db->quote($u); 27 echo "Unquoted : "; 28 var_dump($u); 29 echo "Quoted : "; 30 var_dump($q); 31 32 $db->exec("delete from poq_tab"); 33 34 $db->query("insert into poq_tab (t) values($q)"); 35 $stmt->execute(); 36 var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); 37} 38 39echo "Done\n"; 40 41@$db->exec("drop table poq_tab"); 42 43?> 44--EXPECT-- 45Unquoted : string(0) "" 46Quoted : string(2) "''" 47array(1) { 48 [0]=> 49 array(1) { 50 ["t"]=> 51 NULL 52 } 53} 54Unquoted : string(1) "a" 55Quoted : string(3) "'a'" 56array(1) { 57 [0]=> 58 array(1) { 59 ["t"]=> 60 string(1) "a" 61 } 62} 63Unquoted : string(2) "ab" 64Quoted : string(4) "'ab'" 65array(1) { 66 [0]=> 67 array(1) { 68 ["t"]=> 69 string(2) "ab" 70 } 71} 72Unquoted : string(3) "abc" 73Quoted : string(5) "'abc'" 74array(1) { 75 [0]=> 76 array(1) { 77 ["t"]=> 78 string(3) "abc" 79 } 80} 81Unquoted : string(5) "ab'cd" 82Quoted : string(8) "'ab''cd'" 83array(1) { 84 [0]=> 85 array(1) { 86 ["t"]=> 87 string(5) "ab'cd" 88 } 89} 90Unquoted : string(4) "a\b 91" 92Quoted : string(6) "'a\b 93'" 94array(1) { 95 [0]=> 96 array(1) { 97 ["t"]=> 98 string(4) "a\b 99" 100 } 101} 102Unquoted : string(1) "'" 103Quoted : string(4) "''''" 104array(1) { 105 [0]=> 106 array(1) { 107 ["t"]=> 108 string(1) "'" 109 } 110} 111Unquoted : string(2) "''" 112Quoted : string(6) "''''''" 113array(1) { 114 [0]=> 115 array(1) { 116 ["t"]=> 117 string(2) "''" 118 } 119} 120Unquoted : string(2) "a'" 121Quoted : string(5) "'a'''" 122array(1) { 123 [0]=> 124 array(1) { 125 ["t"]=> 126 string(2) "a'" 127 } 128} 129Unquoted : string(2) "'z" 130Quoted : string(5) "'''z'" 131array(1) { 132 [0]=> 133 array(1) { 134 ["t"]=> 135 string(2) "'z" 136 } 137} 138Unquoted : string(4) "a''b" 139Quoted : string(8) "'a''''b'" 140array(1) { 141 [0]=> 142 array(1) { 143 ["t"]=> 144 string(4) "a''b" 145 } 146} 147Unquoted : string(1) """ 148Quoted : string(3) "'"'" 149array(1) { 150 [0]=> 151 array(1) { 152 ["t"]=> 153 string(1) """ 154 } 155} 156Done 157