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