mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00

This implements a reduced variant of #1226 with just the following change: -Fatal error: Uncaught exception 'EngineException' with message 'Call to private method foo::bar() from context ''' in %s:%d +Fatal error: Uncaught EngineException: Call to private method foo::bar() from context '' in %s:%d The '' wrapper around messages is very weird if the exception message itself contains ''. Futhermore having the message wrapped in '' doesn't work for the "and defined" suffix of TypeExceptions.
62 lines
1.9 KiB
PHP
62 lines
1.9 KiB
PHP
--TEST--
|
|
MySQL PDOStatement->errorCode();
|
|
--SKIPIF--
|
|
<?php
|
|
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
|
|
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
|
MySQLPDOTest::skip();
|
|
$db = MySQLPDOTest::factory();
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
|
$db = MySQLPDOTest::factory();
|
|
|
|
$db->exec('DROP TABLE IF EXISTS ihopeitdoesnotexist');
|
|
|
|
printf("Testing emulated PS...\n");
|
|
try {
|
|
$db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1);
|
|
if (1 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY))
|
|
printf("[002] Unable to turn on emulated prepared statements\n");
|
|
|
|
$stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC');
|
|
$stmt->execute();
|
|
var_dump($stmt->errorCode());
|
|
|
|
|
|
} catch (PDOException $e) {
|
|
printf("[001] %s [%s] %s\n",
|
|
$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
|
|
}
|
|
|
|
printf("Testing native PS...\n");
|
|
try {
|
|
$db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0);
|
|
if (0 != $db->getAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY))
|
|
printf("[004] Unable to turn off emulated prepared statements\n");
|
|
|
|
$stmt = $db->prepare('SELECT id FROM ihopeitdoesnotexist ORDER BY id ASC');
|
|
$stmt->execute();
|
|
var_dump($stmt->errorCode());
|
|
|
|
} catch (PDOException $e) {
|
|
printf("[003] %s [%s] %s\n",
|
|
$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
|
|
}
|
|
|
|
print "done!";
|
|
?>
|
|
--EXPECTF--
|
|
Testing emulated PS...
|
|
|
|
Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d
|
|
string(5) "42S02"
|
|
Testing native PS...
|
|
|
|
Warning: PDO::prepare(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d
|
|
|
|
Fatal error: Uncaught EngineException: Call to a member function execute() on boolean in %s:%d
|
|
Stack trace:
|
|
#0 {main}
|
|
thrown in %s on line %d
|