mirror of
https://github.com/php/php-src.git
synced 2024-11-29 12:53:37 +08:00
Fixed PDORow behaviour and message.
This commit is contained in:
parent
54e2020ee3
commit
b00cd68d74
@ -113,9 +113,10 @@ ZEND_END_ARG_INFO()
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
|
||||
static PHP_FUNCTION(dbstmt_constructor) /* {{{ */
|
||||
static PHP_FUNCTION(dbrow_constructor) /* {{{ */
|
||||
{
|
||||
php_error_docref(NULL, E_ERROR, "You should not create a PDOStatement manually");
|
||||
// php_error_docref(NULL, E_ERROR, "You should not create a PDOStatement manually");
|
||||
zend_throw_exception_ex(php_pdo_get_exception(), 0, "You may not create a PDORow manually");
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -2640,7 +2641,7 @@ static union _zend_function *row_get_ctor(zend_object *object)
|
||||
ctor.type = ZEND_INTERNAL_FUNCTION;
|
||||
ctor.function_name = zend_string_init("__construct", sizeof("__construct") - 1, 0);
|
||||
ctor.scope = pdo_row_ce;
|
||||
ctor.handler = ZEND_FN(dbstmt_constructor);
|
||||
ctor.handler = ZEND_FN(dbrow_constructor);
|
||||
ctor.fn_flags = ZEND_ACC_PUBLIC;
|
||||
|
||||
return (union _zend_function*)&ctor;
|
||||
|
@ -7,17 +7,29 @@ Testing PDORow and PDOStatement instances with Reflection
|
||||
|
||||
$instance = new reflectionclass('pdostatement');
|
||||
$x = $instance->newInstance();
|
||||
var_dump($x);
|
||||
|
||||
$instance = new reflectionclass('pdorow');
|
||||
$x = $instance->newInstance();
|
||||
var_dump($x);
|
||||
if ($x instanceof pdostatement) {
|
||||
echo "Ok".PHP_EOL;
|
||||
}
|
||||
else {
|
||||
echo "Failed to create instance of pdostatment";
|
||||
}
|
||||
|
||||
try {
|
||||
$instance = new reflectionclass('pdorow');
|
||||
$x = $instance->newInstance();
|
||||
echo "Failed to throw exception: ".var_export($x, true);
|
||||
}
|
||||
catch(PDOException $pe) {
|
||||
if ($pe->getMessage() != "You may not create a PDORow manually") {
|
||||
echo "PDOException has wrong message.";
|
||||
}
|
||||
else {
|
||||
echo "Ok".PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
object(PDOStatement)#%d (1) {
|
||||
[%u|b%"queryString"]=>
|
||||
NULL
|
||||
}
|
||||
|
||||
Fatal error: PDORow::__construct(): You should not create a PDOStatement manually in %spdo_036.php on line %d
|
||||
Ok
|
||||
Ok
|
||||
|
@ -5,8 +5,22 @@ Trying instantiate a PDORow object manually
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
new PDORow;
|
||||
try {
|
||||
$instance = new PDORow;
|
||||
echo "Failed to throw exception.".var_export($instance, true);
|
||||
}
|
||||
catch(PDOException $pe) {
|
||||
if ($pe->getMessage() != "You may not create a PDORow manually") {
|
||||
echo "PDOException has wrong message.";
|
||||
}
|
||||
else {
|
||||
echo "Ok".PHP_EOL;
|
||||
}
|
||||
}
|
||||
catch(\Exception $e) {
|
||||
echo "Failed to ";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: PDORow::__construct(): You should not create a PDOStatement manually in %s on line %d
|
||||
Ok
|
||||
|
Loading…
Reference in New Issue
Block a user