georg Fri Jun 17 12:32:43 2005 EDT
Added files:
/php-src/ext/mysqli/tests bug33263.phpt
Modified files:
/php-src/ext/mysqli mysqli_api.c
Log:
fix for bug #33263 (mysqli_real_escape doesn't work in __construct)
http://cvs.php.net/diff.php/php-src/ext/mysqli/mysqli_api.c?r1=1.116&r2=1.117&ty=u
Index: php-src/ext/mysqli/mysqli_api.c
diff -u php-src/ext/mysqli/mysqli_api.c:1.116
php-src/ext/mysqli/mysqli_api.c:1.117
--- php-src/ext/mysqli/mysqli_api.c:1.116 Sat May 21 04:38:53 2005
+++ php-src/ext/mysqli/mysqli_api.c Fri Jun 17 12:32:40 2005
@@ -15,7 +15,7 @@
| Author: Georg Richter <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
- $Id: mysqli_api.c,v 1.116 2005/05/21 08:38:53 georg Exp $
+ $Id: mysqli_api.c,v 1.117 2005/06/17 16:32:40 georg Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -1030,7 +1030,13 @@
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1,
sizeof(MYSQLI_RESOURCE));
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 @@
ulong attr;
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;
}
MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
http://cvs.php.net/co.php/php-src/ext/mysqli/tests/bug33263.phpt?r=1.1&p=1
Index: php-src/ext/mysqli/tests/bug33263.phpt
+++ php-src/ext/mysqli/tests/bug33263.phpt
--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"
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php