Annotation of embedaddon/php/ext/pdo_oci/tests/pdo_oci_quote1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test PDO->quote() for PDO_OCI
3: --SKIPIF--
4: <?php
5: if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded');
6: require(dirname(__FILE__).'/../../pdo/tests/pdo_test.inc');
7: PDOTest::skip();
8: ?>
9: --FILE--
10: <?php
11:
12: require dirname(__FILE__) . '/../../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", '"');
23: foreach ($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:
37: echo "Done\n";
38:
39: @$db->exec("drop table poq_tab");
40:
41: ?>
42: --EXPECTF--
43: Unquoted : NULL
44: Quoted : string(2) "''"
45: array(1) {
46: [0]=>
47: array(1) {
48: ["t"]=>
49: NULL
50: }
51: }
52: Unquoted : string(0) ""
53: Quoted : string(2) "''"
54: array(1) {
55: [0]=>
56: array(1) {
57: ["t"]=>
58: NULL
59: }
60: }
61: Unquoted : string(1) "a"
62: Quoted : string(3) "'a'"
63: array(1) {
64: [0]=>
65: array(1) {
66: ["t"]=>
67: string(1) "a"
68: }
69: }
70: Unquoted : string(2) "ab"
71: Quoted : string(4) "'ab'"
72: array(1) {
73: [0]=>
74: array(1) {
75: ["t"]=>
76: string(2) "ab"
77: }
78: }
79: Unquoted : string(3) "abc"
80: Quoted : string(5) "'abc'"
81: array(1) {
82: [0]=>
83: array(1) {
84: ["t"]=>
85: string(3) "abc"
86: }
87: }
88: Unquoted : string(5) "ab'cd"
89: Quoted : string(8) "'ab''cd'"
90: array(1) {
91: [0]=>
92: array(1) {
93: ["t"]=>
94: string(5) "ab'cd"
95: }
96: }
97: Unquoted : string(4) "a\b
98: "
99: Quoted : string(6) "'a\b
100: '"
101: array(1) {
102: [0]=>
103: array(1) {
104: ["t"]=>
105: string(4) "a\b
106: "
107: }
108: }
109: Unquoted : string(1) "'"
110: Quoted : string(4) "''''"
111: array(1) {
112: [0]=>
113: array(1) {
114: ["t"]=>
115: string(1) "'"
116: }
117: }
118: Unquoted : string(2) "''"
119: Quoted : string(6) "''''''"
120: array(1) {
121: [0]=>
122: array(1) {
123: ["t"]=>
124: string(2) "''"
125: }
126: }
127: Unquoted : string(2) "a'"
128: Quoted : string(5) "'a'''"
129: array(1) {
130: [0]=>
131: array(1) {
132: ["t"]=>
133: string(2) "a'"
134: }
135: }
136: Unquoted : string(2) "'z"
137: Quoted : string(5) "'''z'"
138: array(1) {
139: [0]=>
140: array(1) {
141: ["t"]=>
142: string(2) "'z"
143: }
144: }
145: Unquoted : string(4) "a''b"
146: Quoted : string(8) "'a''''b'"
147: array(1) {
148: [0]=>
149: array(1) {
150: ["t"]=>
151: string(4) "a''b"
152: }
153: }
154: Unquoted : string(1) """
155: Quoted : string(3) "'"'"
156: array(1) {
157: [0]=>
158: array(1) {
159: ["t"]=>
160: string(1) """
161: }
162: }
163: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>