summaryrefslogtreecommitdiff
path: root/ext/mysqli/mysqli_result_iterator.c
diff options
context:
space:
mode:
authorStanley Sufficool <ssufficool@php.net>2014-10-20 21:33:32 -0700
committerStanley Sufficool <ssufficool@php.net>2014-10-20 21:33:32 -0700
commit8defcb855ab01d9c8ab4759cb793d80149b55a8c (patch)
treeed51eb30a2cbc92b102557498fb3e4113da1bb07 /ext/mysqli/mysqli_result_iterator.c
parent9c7dbb0487f5991fde03873ea8f5e66d6688415f (diff)
parentbaddb1c73a170ef1d2c31bd54cddbc6e1ab596b9 (diff)
downloadphp-git-8defcb855ab01d9c8ab4759cb793d80149b55a8c.tar.gz
Merge branch 'master' of https://git.php.net/push/php-src
* 'master' of https://git.php.net/push/php-src: (6215 commits) Extra comma Moved proxy object support in ASSIGN_ADD (and family) from VM to slow paths of corresponding operators Simplification zend_get_property_info_quick() cleanup and optimization initialize lineno before calling compile file file in phar Use ADDREF instead of DUP, it must be enough. Removed old irrelevant comment fixed compilation error Fix bug #68262: Broken reference across cloned objects export functions needed for phpdbg Fixed compilation Optimized property access handlers. Removed EG(std_property_info). Fixed bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads) Don't make difference between undefined and unaccessible properies when call __get() and family Don't make useless CSE array_pop/array_shift optimization check for zlib headers as well as lib for mysqlnd a realpath cache key can be int or float, catching this News entry for new curl constants News entry for new curl constants ...
Diffstat (limited to 'ext/mysqli/mysqli_result_iterator.c')
-rw-r--r--ext/mysqli/mysqli_result_iterator.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/ext/mysqli/mysqli_result_iterator.c b/ext/mysqli/mysqli_result_iterator.c
index 3ea7bafe49..5caa926b47 100644
--- a/ext/mysqli/mysqli_result_iterator.c
+++ b/ext/mysqli/mysqli_result_iterator.c
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2013 The PHP Group |
+ | Copyright (c) 1997-2014 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 |
@@ -38,7 +38,7 @@ extern zend_object_iterator_funcs php_mysqli_result_iterator_funcs;
typedef struct {
zend_object_iterator intern;
mysqli_object *result;
- zval *current_row;
+ zval current_row;
my_longlong row_num;
} php_mysqli_result_iterator;
@@ -52,55 +52,46 @@ zend_object_iterator *php_mysqli_result_get_iterator(zend_class_entry *ce, zval
zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
}
iterator = ecalloc(1, sizeof(php_mysqli_result_iterator));
+ zend_iterator_init(&iterator->intern TSRMLS_CC);
- Z_ADDREF_P(object);
- iterator->intern.data = (void*)object;
+ ZVAL_COPY(&iterator->intern.data, object);
iterator->intern.funcs = &php_mysqli_result_iterator_funcs;
- iterator->result = (mysqli_object *) zend_object_store_get_object(object TSRMLS_CC);
+ iterator->result = Z_MYSQLI_P(object);
iterator->row_num = -1;
- return (zend_object_iterator*)iterator;
+ return &iterator->intern;
}
/* }}} */
-
/* {{{ */
static void php_mysqli_result_iterator_dtor(zend_object_iterator *iter TSRMLS_DC)
{
- php_mysqli_result_iterator *iterator = (php_mysqli_result_iterator*) iter;
+ 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);
+ zval_ptr_dtor(&iterator->intern.data);
+ zval_ptr_dtor(&iterator->current_row);
}
/* }}} */
-
/* {{{ */
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;
+ return Z_TYPE(iterator->current_row) == IS_ARRAY ? SUCCESS : FAILURE;
}
/* }}} */
-
/* {{{ */
-static void php_mysqli_result_iterator_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC)
+static zval *php_mysqli_result_iterator_current_data(zend_object_iterator *iter TSRMLS_DC)
{
php_mysqli_result_iterator *iterator = (php_mysqli_result_iterator*) iter;
- *data = &iterator->current_row;
+ return &iterator->current_row;
}
/* }}} */
-
/* {{{ */
static void php_mysqli_result_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC)
{
@@ -110,18 +101,15 @@ static void php_mysqli_result_iterator_move_forward(zend_object_iterator *iter T
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) {
+
+ zval_ptr_dtor(&iterator->current_row);
+ php_mysqli_fetch_into_hash_aux(&iterator->current_row, result, MYSQLI_ASSOC TSRMLS_CC);
+ if (Z_TYPE(iterator->current_row) == IS_ARRAY) {
iterator->row_num++;
}
}
/* }}} */
-
/* {{{ */
static void php_mysqli_result_iterator_rewind(zend_object_iterator *iter TSRMLS_DC)
{
@@ -148,7 +136,6 @@ static void php_mysqli_result_iterator_rewind(zend_object_iterator *iter TSRMLS_
}
/* }}} */
-
/* {{{ php_mysqli_result_iterator_current_key */
static void php_mysqli_result_iterator_current_key(zend_object_iterator *iter, zval *key TSRMLS_DC)
{
@@ -158,7 +145,6 @@ static void php_mysqli_result_iterator_current_key(zend_object_iterator *iter, z
}
/* }}} */
-
/* {{{ php_mysqli_result_iterator_funcs */
zend_object_iterator_funcs php_mysqli_result_iterator_funcs = {
php_mysqli_result_iterator_dtor,
@@ -170,7 +156,6 @@ zend_object_iterator_funcs php_mysqli_result_iterator_funcs = {
};
/* }}} */
-
/*
* Local variables:
* tab-width: 4