summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2010-05-18 10:39:26 +0000
committerAndrey Hristov <andrey@php.net>2010-05-18 10:39:26 +0000
commit7dd13d56ccd811c45245b0fb2759dc856dd90b80 (patch)
tree351e83c2e0414536496d20f0f2fedd881f49178d
parent50cda403b1cfc71c84536a0f4dad751cf049c4e5 (diff)
downloadphp-git-7dd13d56ccd811c45245b0fb2759dc856dd90b80.tar.gz
Add iterator to mysqli_result. Works both for :
- USE_RESULT, can be iterated only once, kind of forward iterator - STORE_RESULT, can be iterated multiple times
-rw-r--r--ext/mysqli/config.m42
-rw-r--r--ext/mysqli/config.w321
-rw-r--r--ext/mysqli/mysqli.c109
-rw-r--r--ext/mysqli/mysqli_libmysql.h24
-rw-r--r--ext/mysqli/mysqli_result_iterator.c184
-rw-r--r--ext/mysqli/php_mysqli_structs.h23
-rw-r--r--ext/mysqli/tests/mysqli_query_iterators.phpt201
7 files changed, 482 insertions, 62 deletions
diff --git a/ext/mysqli/config.m4 b/ext/mysqli/config.m4
index 2c1cf78ecc..5119c5cc0a 100644
--- a/ext/mysqli/config.m4
+++ b/ext/mysqli/config.m4
@@ -77,7 +77,7 @@ dnl Build extension
if test "$PHP_MYSQLI" != "no"; then
mysqli_sources="mysqli.c mysqli_api.c mysqli_prop.c mysqli_nonapi.c \
mysqli_fe.c mysqli_report.c mysqli_driver.c mysqli_warning.c \
- mysqli_exception.c $mysqli_extra_sources"
+ mysqli_exception.c mysqli_result_iterator.c $mysqli_extra_sources"
PHP_NEW_EXTENSION(mysqli, $mysqli_sources, $ext_shared)
PHP_SUBST(MYSQLI_SHARED_LIBADD)
diff --git a/ext/mysqli/config.w32 b/ext/mysqli/config.w32
index 8ea72a06db..30def9424d 100644
--- a/ext/mysqli/config.w32
+++ b/ext/mysqli/config.w32
@@ -18,6 +18,7 @@ if (PHP_MYSQLI != "no") {
"mysqli_fe.c " +
"mysqli_nonapi.c " +
"mysqli_prop.c " +
+ "mysqli_result_iterator.c " +
"mysqli_report.c " +
"mysqli_warning.c";
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index 61b806a348..a82a3f1716 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -32,6 +32,7 @@
#include "ext/standard/php_string.h"
#include "php_mysqli_structs.h"
#include "zend_exceptions.h"
+#include "zend_interfaces.h"
ZEND_DECLARE_MODULE_GLOBALS(mysqli)
static PHP_GINIT_FUNCTION(mysqli);
@@ -685,6 +686,9 @@ PHP_MINIT_FUNCTION(mysqli)
zend_hash_init(&mysqli_result_properties, 0, NULL, NULL, 1);
MYSQLI_ADD_PROPERTIES(&mysqli_result_properties, mysqli_result_property_entries);
MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_result_property_info_entries);
+ mysqli_result_class_entry->get_iterator = php_mysqli_result_get_iterator;
+ mysqli_result_class_entry->iterator_funcs.funcs = &php_mysqli_result_iterator_funcs;
+ zend_class_implements(mysqli_result_class_entry TSRMLS_CC, 1, zend_ce_traversable);
zend_hash_add(&classes, ce->name, ce->name_length+1, &mysqli_result_properties, sizeof(mysqli_result_properties), NULL);
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_stmt", mysqli_stmt_class_entry, mysqli_stmt_methods);
@@ -1072,58 +1076,15 @@ PHP_FUNCTION(mysqli_result_construct)
}
/* }}} */
-/* {{{ php_mysqli_fetch_into_hash
+
+/* {{{ php_mysqli_fetch_into_hash_aux
*/
-void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags, int into_object)
+void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, long fetchtype TSRMLS_DC)
{
- MYSQL_RES *result;
- zval *mysql_result;
- long fetchtype;
- zval *ctor_params = NULL;
- zend_class_entry *ce = NULL;
-#if !defined(MYSQLI_USE_MYSQLND)
+ MYSQL_ROW row;
unsigned int i;
MYSQL_FIELD *fields;
- MYSQL_ROW row;
unsigned long *field_len;
-#endif
-
- if (into_object) {
- char *class_name;
- int class_name_len;
-
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|sz", &mysql_result, mysqli_result_class_entry, &class_name, &class_name_len, &ctor_params) == FAILURE) {
- return;
- }
- if (ZEND_NUM_ARGS() < (getThis() ? 1 : 2)) {
- ce = zend_standard_class_def;
- } else {
- ce = zend_fetch_class(class_name, class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
- }
- if (!ce) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not find class '%s'", class_name);
- return;
- }
- fetchtype = MYSQLI_ASSOC;
- } else {
- if (override_flags) {
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
- return;
- }
- fetchtype = override_flags;
- } else {
- fetchtype = MYSQLI_BOTH;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &fetchtype) == FAILURE) {
- return;
- }
- }
- }
- MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
-
- if (fetchtype < MYSQLI_ASSOC || fetchtype > MYSQLI_BOTH) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH");
- RETURN_FALSE;
- }
#if !defined(MYSQLI_USE_MYSQLND)
if (!(row = mysql_fetch_row(result))) {
@@ -1195,8 +1156,60 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
}
}
#else
- mysqlnd_fetch_into(result, MYSQLND_FETCH_ASSOC, return_value, MYSQLND_MYSQLI);
+ mysqlnd_fetch_into(result, ((fetchtype & MYSQLI_NUM)? MYSQLND_FETCH_NUM:0) | ((fetchtype & MYSQLI_ASSOC)? MYSQLND_FETCH_ASSOC:0), return_value, MYSQLND_MYSQLI);
#endif
+}
+/* }}} */
+
+
+/* {{{ php_mysqli_fetch_into_hash
+ */
+void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags, int into_object)
+{
+ MYSQL_RES *result;
+ zval *mysql_result;
+ long fetchtype;
+ zval *ctor_params = NULL;
+ zend_class_entry *ce = NULL;
+
+ if (into_object) {
+ char *class_name;
+ int class_name_len;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|sz", &mysql_result, mysqli_result_class_entry, &class_name, &class_name_len, &ctor_params) == FAILURE) {
+ return;
+ }
+ if (ZEND_NUM_ARGS() < (getThis() ? 1 : 2)) {
+ ce = zend_standard_class_def;
+ } else {
+ ce = zend_fetch_class(class_name, class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
+ }
+ if (!ce) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not find class '%s'", class_name);
+ return;
+ }
+ fetchtype = MYSQLI_ASSOC;
+ } else {
+ if (override_flags) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
+ return;
+ }
+ fetchtype = override_flags;
+ } else {
+ fetchtype = MYSQLI_BOTH;
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &fetchtype) == FAILURE) {
+ return;
+ }
+ }
+ }
+ MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
+
+ if (fetchtype < MYSQLI_ASSOC || fetchtype > MYSQLI_BOTH) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH");
+ RETURN_FALSE;
+ }
+
+ php_mysqli_fetch_into_hash_aux(return_value, result, fetchtype TSRMLS_CC);
if (into_object && Z_TYPE_P(return_value) != IS_NULL) {
zval dataset = *return_value;
diff --git a/ext/mysqli/mysqli_libmysql.h b/ext/mysqli/mysqli_libmysql.h
index 8e0c735b1a..642a56ae53 100644
--- a/ext/mysqli/mysqli_libmysql.h
+++ b/ext/mysqli/mysqli_libmysql.h
@@ -1,9 +1,9 @@
/*
- ----------------------------------------------------------------------
- | PHP Version 6 |
- ----------------------------------------------------------------------
- | Copyright (c) 2007 The PHP Group |
- ----------------------------------------------------------------------
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2010 The PHP Group |
+ +----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
@@ -11,12 +11,11 @@
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
- ----------------------------------------------------------------------
- | Authors: Georg Richter <georg@mysql.com> |
- | Andrey Hristov <andrey@mysql.com> |
- | Ulf Wendel <uwendel@mysql.com> |
- ----------------------------------------------------------------------
-
+ +----------------------------------------------------------------------+
+ | Authors: Georg Richter <georg@php.net> |
+ | Andrey Hristov <andrey@php.net> |
+ | Ulf Wendel <uw@php.net> |
+ +----------------------------------------------------------------------+
*/
#ifndef MYSQLI_LIBMYSQL_H
@@ -29,7 +28,8 @@
#define MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE 200
#define MYSQLND_OPT_INT_AND_YEAR_AS_INT 201
-#define mysqli_result_is_unbuffered(r) ((r)->handle && (r)->handle->status == MYSQL_STATUS_USE_RESULT)
+/* r->data should be always NULL, at least in recent libmysql versions, the status changes once data is read*/
+#define mysqli_result_is_unbuffered(r) (((r)->handle && (r)->handle->status == MYSQL_STATUS_USE_RESULT) || ((r)->data == NULL))
#define mysqli_server_status(c) (c)->server_status
#define mysqli_stmt_get_id(s) ((s)->stmt_id)
#define mysqli_stmt_warning_count(s) mysql_warning_count((s)->mysql)
diff --git a/ext/mysqli/mysqli_result_iterator.c b/ext/mysqli/mysqli_result_iterator.c
new file mode 100644
index 0000000000..3dea18d508
--- /dev/null
+++ b/ext/mysqli/mysqli_result_iterator.c
@@ -0,0 +1,184 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2010 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Georg Richter <georg@php.net> |
+ | Andrey Hristov <andrey@php.net> |
+ | Ulf Wendel <uw@php.net> |
+ +----------------------------------------------------------------------+
+
+ $Id: mysqli.c 299335 2010-05-13 11:05:09Z andrey $
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <signal.h>
+
+#include "php.h"
+#include "php_ini.h"
+#include "php_mysqli_structs.h"
+#include "zend_interfaces.h"
+
+
+extern zend_object_iterator_funcs php_mysqli_result_iterator_funcs;
+
+typedef struct {
+ zend_object_iterator intern;
+ mysqli_object *result;
+ zval *current_row;
+ my_longlong row_num;
+} php_mysqli_result_iterator;
+
+
+/* {{{ */
+zend_object_iterator *php_mysqli_result_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)
+{
+ php_mysqli_result_iterator *iterator;
+
+ if (by_ref) {
+ zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
+ }
+ iterator = ecalloc(1, sizeof(php_mysqli_result_iterator));
+
+ Z_ADDREF_P(object);
+ iterator->intern.data = (void*)object;
+ iterator->intern.funcs = &php_mysqli_result_iterator_funcs;
+ iterator->result = (mysqli_object *) zend_object_store_get_object(object TSRMLS_CC);
+ iterator->row_num = -1;
+
+ return (zend_object_iterator*)iterator;
+}
+/* }}} */
+
+
+/* {{{ */
+static void php_mysqli_result_iterator_dtor(zend_object_iterator *iter TSRMLS_DC)
+{
+ php_mysqli_result_iterator *iterator = (php_mysqli_result_iterator*) iter;
+
+ /* cleanup handled in sxe_object_dtor as we dont always have an iterator wrapper */
+ if (iterator->intern.data) {
+ zval_ptr_dtor((zval**)&iterator->intern.data);
+ }
+ if (iterator->current_row) {
+ zval_ptr_dtor(&iterator->current_row);
+ }
+ efree(iterator);
+}
+/* }}} */
+
+
+/* {{{ */
+static int php_mysqli_result_iterator_valid(zend_object_iterator *iter TSRMLS_DC)
+{
+ php_mysqli_result_iterator *iterator = (php_mysqli_result_iterator*) iter;
+
+ return iterator->current_row && Z_TYPE_P(iterator->current_row) == IS_ARRAY ? SUCCESS : FAILURE;
+}
+/* }}} */
+
+
+/* {{{ */
+static void php_mysqli_result_iterator_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC)
+{
+ php_mysqli_result_iterator *iterator = (php_mysqli_result_iterator*) iter;
+
+ *data = &iterator->current_row;
+}
+/* }}} */
+
+
+/* {{{ */
+static void php_mysqli_result_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC)
+{
+
+ php_mysqli_result_iterator *iterator = (php_mysqli_result_iterator*) iter;
+ mysqli_object *intern = iterator->result;
+ MYSQL_RES *result;
+
+ MYSQLI_FETCH_RESOURCE_BY_OBJ(result, MYSQL_RES *, intern, "mysqli_result", MYSQLI_STATUS_VALID);
+ if (iterator->current_row) {
+ zval_ptr_dtor(&iterator->current_row);
+ }
+ MAKE_STD_ZVAL(iterator->current_row);
+ php_mysqli_fetch_into_hash_aux(iterator->current_row, result, MYSQLI_ASSOC TSRMLS_CC);
+ if (Z_TYPE_P(iterator->current_row) == IS_ARRAY) {
+ iterator->row_num++;
+ }
+}
+/* }}} */
+
+
+/* {{{ */
+static void php_mysqli_result_iterator_rewind(zend_object_iterator *iter TSRMLS_DC)
+{
+ php_mysqli_result_iterator *iterator = (php_mysqli_result_iterator*) iter;
+ mysqli_object *intern = iterator->result;
+ MYSQL_RES *result;
+
+ MYSQLI_FETCH_RESOURCE_BY_OBJ(result, MYSQL_RES *, intern, "mysqli_result", MYSQLI_STATUS_VALID);
+
+ if (mysqli_result_is_unbuffered(result)) {
+#if MYSQLI_USE_MYSQLND
+ if (result->unbuf && result->unbuf->eof_reached) {
+#else
+ if (result->eof) {
+#endif
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Data fetched with MYSQLI_USE_RESULT can be iterated only once");
+ return;
+ }
+ } else {
+ mysql_data_seek(result, 0);
+ }
+ iterator->row_num = -1;
+ php_mysqli_result_iterator_move_forward(iter TSRMLS_CC);
+}
+/* }}} */
+
+
+/* {{{ */
+/* PHP6 has the following declaration
+ static int php_mysqli_result_iterator_current_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+*/
+static int php_mysqli_result_iterator_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+{
+ php_mysqli_result_iterator *iterator = (php_mysqli_result_iterator*) iter;
+
+ *int_key = iterator->row_num;
+ return HASH_KEY_IS_LONG;
+}
+/* }}} */
+
+
+/* {{{ php_mysqli_result_iterator_funcs */
+zend_object_iterator_funcs php_mysqli_result_iterator_funcs = {
+ php_mysqli_result_iterator_dtor,
+ php_mysqli_result_iterator_valid,
+ php_mysqli_result_iterator_current_data,
+ php_mysqli_result_iterator_current_key,
+ php_mysqli_result_iterator_move_forward,
+ php_mysqli_result_iterator_rewind,
+};
+/* }}} */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h
index 5712150d58..baa173e34c 100644
--- a/ext/mysqli/php_mysqli_structs.h
+++ b/ext/mysqli/php_mysqli_structs.h
@@ -12,7 +12,9 @@
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
- | Author: Georg Richter <georg@php.net> |
+ | Authors: Georg Richter <georg@php.net> |
+ | Andrey Hristov <andrey@php.net> |
+ | Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
$Id$
@@ -217,6 +219,10 @@ extern void php_mysqli_dtor_p_elements(void *data);
extern void php_mysqli_close(MY_MYSQL * mysql, int close_type, int resource_status TSRMLS_DC);
+extern zend_object_iterator_funcs php_mysqli_result_iterator_funcs;
+extern zend_object_iterator *php_mysqli_result_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
+
+extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, long fetchtype TSRMLS_DC);
#ifdef HAVE_SPL
extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
@@ -275,6 +281,21 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRML
}\
}
+#define MYSQLI_FETCH_RESOURCE_BY_OBJ(__ptr, __type, __obj, __name, __check) \
+{ \
+ MYSQLI_RESOURCE *my_res; \
+ if (!(my_res = (MYSQLI_RESOURCE *)(__obj->ptr))) {\
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", intern->zo.ce->name);\
+ return;\
+ }\
+ __ptr = (__type)my_res->ptr; \
+ if (__check && my_res->status < __check) { \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid object or resource %s\n", intern->zo.ce->name); \
+ return;\
+ }\
+}
+
+
#define MYSQLI_SET_STATUS(__id, __value) \
{ \
mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\
diff --git a/ext/mysqli/tests/mysqli_query_iterators.phpt b/ext/mysqli/tests/mysqli_query_iterators.phpt
new file mode 100644
index 0000000000..2577aa76ee
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_query_iterators.phpt
@@ -0,0 +1,201 @@
+--TEST--
+mysqli iterators
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+ require_once("connect.inc");
+
+ $tmp = NULL;
+ $link = NULL;
+
+ require('table.inc');
+
+ echo "--- Testing default ---\n";
+ if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id")))
+ printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ else {
+ foreach ($res as $row) {
+ var_dump($row);
+ }
+ echo "======\n";
+ foreach ($res as $row) {
+ var_dump($row);
+ }
+ mysqli_free_result($res);
+ foreach ($res as $row) {
+ var_dump($row);
+ }
+ }
+ echo "--- Testing USE_RESULT ---\n";
+ if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_USE_RESULT)))
+ printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ else {
+ foreach ($res as $row) {
+ var_dump($row);
+ }
+ echo "======\n";
+ foreach ($res as $row) {
+ var_dump($row);
+ }
+ mysqli_free_result($res);
+ }
+
+ echo "--- Testing STORE_RESULT ---\n";
+ if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_STORE_RESULT)))
+ printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ else {
+ foreach ($res as $row) {
+ var_dump($row);
+ }
+ echo "======\n";
+ foreach ($res as $row) {
+ var_dump($row);
+ }
+ mysqli_free_result($res);
+ }
+
+ mysqli_close($link);
+
+ print "done!";
+?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
+--EXPECTF--
+--- Testing default ---
+array(1) {
+ ["id"]=>
+ string(1) "1"
+}
+array(1) {
+ ["id"]=>
+ string(1) "2"
+}
+array(1) {
+ ["id"]=>
+ string(1) "3"
+}
+array(1) {
+ ["id"]=>
+ string(1) "4"
+}
+array(1) {
+ ["id"]=>
+ string(1) "5"
+}
+array(1) {
+ ["id"]=>
+ string(1) "6"
+}
+======
+array(1) {
+ ["id"]=>
+ string(1) "1"
+}
+array(1) {
+ ["id"]=>
+ string(1) "2"
+}
+array(1) {
+ ["id"]=>
+ string(1) "3"
+}
+array(1) {
+ ["id"]=>
+ string(1) "4"
+}
+array(1) {
+ ["id"]=>
+ string(1) "5"
+}
+array(1) {
+ ["id"]=>
+ string(1) "6"
+}
+
+Warning: main(): Couldn't fetch mysqli_result in %s on line %d
+--- Testing USE_RESULT ---
+array(1) {
+ ["id"]=>
+ string(1) "1"
+}
+array(1) {
+ ["id"]=>
+ string(1) "2"
+}
+array(1) {
+ ["id"]=>
+ string(1) "3"
+}
+array(1) {
+ ["id"]=>
+ string(1) "4"
+}
+array(1) {
+ ["id"]=>
+ string(1) "5"
+}
+array(1) {
+ ["id"]=>
+ string(1) "6"
+}
+======
+
+Warning: main(): Data fetched with MYSQLI_USE_RESULT can be iterated only once in %s on line %d
+--- Testing STORE_RESULT ---
+array(1) {
+ ["id"]=>
+ string(1) "1"
+}
+array(1) {
+ ["id"]=>
+ string(1) "2"
+}
+array(1) {
+ ["id"]=>
+ string(1) "3"
+}
+array(1) {
+ ["id"]=>
+ string(1) "4"
+}
+array(1) {
+ ["id"]=>
+ string(1) "5"
+}
+array(1) {
+ ["id"]=>
+ string(1) "6"
+}
+======
+array(1) {
+ ["id"]=>
+ string(1) "1"
+}
+array(1) {
+ ["id"]=>
+ string(1) "2"
+}
+array(1) {
+ ["id"]=>
+ string(1) "3"
+}
+array(1) {
+ ["id"]=>
+ string(1) "4"
+}
+array(1) {
+ ["id"]=>
+ string(1) "5"
+}
+array(1) {
+ ["id"]=>
+ string(1) "6"
+}
+done! \ No newline at end of file