size_t statement_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s!", &mysql_link, mysqli_link_class_entry, &statement, &statement_len) == FAILURE) {
- return;
+ RETURN_THROWS();
}
-
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
stmt = (MY_STMT *) ecalloc(1, sizeof(MY_STMT));
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
mysqli_resource->ptr = (void *)stmt;
- mysqli_resource->status = (ZEND_NUM_ARGS() == 1) ? MYSQLI_STATUS_INITIALIZED : MYSQLI_STATUS_VALID;
+ mysqli_resource->status = MYSQLI_STATUS_INITIALIZED;
MYSQLI_REGISTER_RESOURCE_EX(mysqli_resource, getThis());
+
+ if (statement) {
+ if(mysql_stmt_prepare(stmt->stmt, statement, statement_len)) {
+ MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
+ RETURN_FALSE;
+ }
+ mysqli_resource->status = MYSQLI_STATUS_VALID;
+ }
}
-/* }}} */
-/* {{{ mixed mysqli_result_construct()
-constructor for result object.
-Parameters:
- object [, mode] -> mysqli_store/use_result
-*/
-PHP_FUNCTION(mysqli_result_construct)
+PHP_METHOD(mysqli_result, __construct)
{
MY_MYSQL *mysql;
MYSQL_RES *result = NULL;