fix for bug #33263 (mysqli_real_escape doesn't work in __construct)

This commit is contained in:
Georg Richter 2005-06-17 16:32:43 +00:00
parent 987f6f8fcf
commit 15563f8d91
2 changed files with 39 additions and 2 deletions

View File

@ -1030,7 +1030,13 @@ PHP_FUNCTION(mysqli_init)
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = (void *)mysql; mysqli_resource->ptr = (void *)mysql;
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry);
if (!getThis()) {
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry);
} else {
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->ptr = mysqli_resource;
((mysqli_object *) zend_object_store_get_object(getThis() TSRMLS_CC))->valid = 1;
}
} }
/* }}} */ /* }}} */
@ -1743,7 +1749,7 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
ulong attr; ulong attr;
int rc; int rc;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olb", &mysql_stmt, mysqli_stmt_class_entry, &attr, &mode) == FAILURE) { if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll", &mysql_stmt, mysqli_stmt_class_entry, &attr, &mode) == FAILURE) {
return; return;
} }
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt"); MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");

View File

@ -0,0 +1,31 @@
--TEST--
bug #33263 (mysqli_real_connect in __construct)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
include "connect.inc";
class test extends mysqli
{
public function __construct($host, $user, $passwd, $db) {
parent::init();
parent::real_connect($host, $user, $passwd, $db);
}
}
$mysql = new test($host, $user, $passwd, "test");
$stmt = $mysql->prepare("SELECT DATABASE()");
$stmt->execute();
$stmt->bind_result($db);
$stmt->fetch();
$stmt->close();
var_dump($db);
$mysql->close();
?>
--EXPECT--
string(4) "test"