php-src/ext/pdo/tests/pdo_033.phpt
Máté Kocsis f4a5db3e08
Parallelize pdo tests (dblib, firebird, oci, odbc, pgsql) (#12395)
Co-authored-by: George Peter Banyard <girgias@php.net>
Co-authored-by: Jorg Adam Sowa <jorg.sowa@gmail.com>
2023-10-28 12:35:57 +01:00

48 lines
1.2 KiB
PHP

--TEST--
PDO Common: PDO::quote()
--EXTENSIONS--
pdo
--SKIPIF--
<?php
$dir = getenv('REDIR_TEST_DIR');
if (false == $dir) die('skip no driver');
if (!strncasecmp(getenv('PDOTEST_DSN'), 'odbc', strlen('odbc'))) die('skip odbc driver doesn\'t have escape API, use prepared statements');
require_once $dir . 'pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory();
$unquoted = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
$quoted = $db->quote($unquoted);
$len = strlen($unquoted);
$db->query("CREATE TABLE test033 (t char($len))");
$db->query("INSERT INTO test033 (t) VALUES($quoted)");
$stmt = $db->prepare('SELECT * from test033');
$stmt->execute();
print_r($stmt->fetchAll(PDO::FETCH_ASSOC));
?>
--CLEAN--
<?php
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory();
PDOTest::dropTableIfExists($db, "test033");
?>
--EXPECT--
Array
(
[0] => Array
(
[t] => !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
)
)