xref: /PHP-5.3/ext/pdo/tests/pdo_033.phpt (revision b66f9c0a)
1--TEST--
2PDO Common: PDO::quote()
3--SKIPIF--
4<?php # vim:ft=php
5if (!extension_loaded('pdo')) die('skip');
6$dir = getenv('REDIR_TEST_DIR');
7if (false == $dir) die('skip no driver');
8require_once $dir . 'pdo_test.inc';
9PDOTest::skip();
10?>
11--FILE--
12<?php
13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
15$db = PDOTest::factory();
16
17$unquoted = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
18
19$quoted = $db->quote($unquoted);
20
21$len = strlen($unquoted);
22
23@$db->exec("DROP TABLE test");
24
25$db->query("CREATE TABLE test (t char($len))");
26$db->query("INSERT INTO test (t) VALUES($quoted)");
27
28$stmt = $db->prepare('SELECT * from test');
29$stmt->execute();
30
31print_r($stmt->fetchAll(PDO::FETCH_ASSOC));
32
33$db->exec("DROP TABLE test");
34
35?>
36--EXPECT--
37Array
38(
39    [0] => Array
40        (
41            [t] =>  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
42        )
43
44)
45