Skip to content

Commit

Permalink
Merge pull request #1686 from sjinks/issue-1642
Browse files Browse the repository at this point in the history
#1642: use fetchAll() instead of fetch() in Phalcon\Db\Adapter::fetchAll()
  • Loading branch information
Phalcon committed Dec 15, 2013
2 parents a32e4f7 + af105b8 commit b71b63d
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions ext/db/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ PHP_METHOD(Phalcon_Db_Adapter, fetchOne){
PHP_METHOD(Phalcon_Db_Adapter, fetchAll){

zval *sql_query, *fetch_mode = NULL, *bind_params = NULL, *bind_types = NULL;
zval *result, *row = NULL;
zval *r0 = NULL;
zval *result;

PHALCON_MM_GROW();

Expand All @@ -284,26 +283,14 @@ PHP_METHOD(Phalcon_Db_Adapter, fetchAll){
bind_types = PHALCON_GLOBAL(z_null);
}

array_init(return_value);

PHALCON_INIT_VAR(result);
phalcon_call_method_p3(result, this_ptr, "query", sql_query, bind_params, bind_types);
if (likely(Z_TYPE_P(result) == IS_OBJECT)) {
if (Z_TYPE_P(fetch_mode) != IS_NULL) {
phalcon_call_method_p1_noret(result, "setfetchmode", fetch_mode);
}

while (1) {

PHALCON_INIT_NVAR(r0);
phalcon_call_method(r0, result, "fetch");
PHALCON_CPY_WRT(row, r0);
if (!zend_is_true(row)) {
break;
}

phalcon_array_append(&return_value, row, 0);
}

phalcon_return_call_method_p0(result, "fetchall");
}

PHALCON_MM_RESTORE();
Expand Down

0 comments on commit b71b63d

Please sign in to comment.