diff options
Diffstat (limited to 'ext/mysqli/mysqli_api.c')
| -rw-r--r-- | ext/mysqli/mysqli_api.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 95bcd9978c..8eae59b0c1 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1479,19 +1479,12 @@ PHP_FUNCTION(mysqli_info) /* }}} */ /* {{{ php_mysqli_init() */ -void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS) +void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_method) { MYSQLI_RESOURCE *mysqli_resource; MY_MYSQL *mysql; -// TODO: We can't properly check if this was to mysql_init() in a class method -// or a call to mysqli->init(). -// To solve the problem, we added instanceof check for the class of $this -// ??? - if (getThis() && - instanceof_function(Z_OBJCE_P(getThis()), mysqli_link_class_entry) && - (Z_MYSQLI_P(getThis()))->ptr) { -//??? if (getThis() && (Z_MYSQLI_P(getThis()))->ptr) { + if (is_method && (Z_MYSQLI_P(getThis()))->ptr) { return; } @@ -1515,7 +1508,7 @@ void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS) mysqli_resource->ptr = (void *)mysql; mysqli_resource->status = MYSQLI_STATUS_INITIALIZED; - if (!getThis() || !instanceof_function(Z_OBJCE_P(getThis()), mysqli_link_class_entry)) { + if (!is_method) { MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry); } else { (Z_MYSQLI_P(getThis()))->ptr = mysqli_resource; @@ -1527,7 +1520,15 @@ void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS) Initialize mysqli and return a resource for use with mysql_real_connect */ PHP_FUNCTION(mysqli_init) { - php_mysqli_init(INTERNAL_FUNCTION_PARAM_PASSTHRU); + php_mysqli_init(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE); +} +/* }}} */ + +/* {{{ proto resource mysqli::init(void) + Initialize mysqli and return a resource for use with mysql_real_connect */ +PHP_FUNCTION(mysqli_init_method) +{ + php_mysqli_init(INTERNAL_FUNCTION_PARAM_PASSTHRU, TRUE); } /* }}} */ |
