mirror of
https://github.com/php/php-src.git
synced 2024-12-01 05:43:38 +08:00
39131219e8
This is a mix of more automated and manual migration. It should remove all applicable extension_loaded() checks outside of skipif.inc files.
63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
--TEST--
|
|
Bug #50323 (No ability to connect to database named 't;', no chance to escape semicolon)
|
|
--EXTENSIONS--
|
|
pdo
|
|
pdo_mysql
|
|
--SKIPIF--
|
|
<?php
|
|
require __DIR__ . '/config.inc';
|
|
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
|
PDOTest::skip();
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
|
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
|
|
|
function changeDSN($original, $new_options) {
|
|
$old_options = array();
|
|
$dsn = substr($original,
|
|
strpos($original, ':') + 1,
|
|
strlen($original));
|
|
|
|
// no real parser - any exotic setting can fool us
|
|
$parts = explode(';', $dsn);
|
|
foreach ($parts as $k => $v) {
|
|
$tmp = explode('=', $v);
|
|
if (count($tmp) == 2)
|
|
$old_options[$tmp[0]] = $tmp[1];
|
|
}
|
|
|
|
$options = $old_options;
|
|
foreach ($new_options as $k => $v)
|
|
$options[$k] = $v;
|
|
|
|
$dsn = 'mysql:';
|
|
foreach ($options as $k => $v)
|
|
$dsn .= sprintf('%s=%s;', $k, $v);
|
|
|
|
$dsn = substr($dsn, 0, strlen($dsn) -1);
|
|
|
|
return $dsn;
|
|
}
|
|
|
|
|
|
if (1 === @$db->exec('CREATE DATABASE `crazy;dbname`')) {
|
|
$dsn = changeDSN(getenv('PDOTEST_DSN'), array('dbname' => 'crazy;;dbname'));
|
|
$user = getenv('PDOTEST_USER');
|
|
$pass = getenv('PDOTEST_PASS');
|
|
|
|
new PDO($dsn, $user, $pass);
|
|
}
|
|
echo 'done!';
|
|
?>
|
|
--CLEAN--
|
|
<?php
|
|
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
|
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
|
|
|
@$db->exec('DROP DATABASE IF EXISTS `crazy;dbname`');
|
|
?>
|
|
--EXPECT--
|
|
done!
|