1--TEST-- 2Bug #50323 (No ability to connect to database named 't;', no chance to escape semicolon) 3--SKIPIF-- 4<?php 5if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded'); 6require dirname(__FILE__) . '/config.inc'; 7require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; 8PDOTest::skip(); 9?> 10--FILE-- 11<?php 12require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; 13$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); 14 15 function changeDSN($original, $new_options) { 16 $old_options = array(); 17 $dsn = substr($original, 18 strpos($original, ':') + 1, 19 strlen($original)); 20 21 // no real parser - any exotic setting can fool us 22 $parts = explode(';', $dsn); 23 foreach ($parts as $k => $v) { 24 $tmp = explode('=', $v); 25 if (count($tmp) == 2) 26 $old_options[$tmp[0]] = $tmp[1]; 27 } 28 29 $options = $old_options; 30 foreach ($new_options as $k => $v) 31 $options[$k] = $v; 32 33 $dsn = 'mysql:'; 34 foreach ($options as $k => $v) 35 $dsn .= sprintf('%s=%s;', $k, $v); 36 37 $dsn = substr($dsn, 0, strlen($dsn) -1); 38 39 return $dsn; 40 } 41 42 43if (1 === @$db->exec('CREATE DATABASE `crazy;dbname`')) { 44 $dsn = changeDSN(getenv('PDOTEST_DSN'), array('dbname' => 'crazy;;dbname')); 45 $user = getenv('PDOTEST_USER'); 46 $pass = getenv('PDOTEST_PASS'); 47 48 new PDO($dsn, $user, $pass); 49} 50echo 'done!'; 51?> 52--CLEAN-- 53<?php 54require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; 55$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); 56 57@$db->exec('DROP DATABASE IF EXISTS `crazy;dbname`'); 58?> 59--EXPECT-- 60done! 61