]> granicus.if.org Git - php/commitdiff
Return an empty array rather then FALSE in fetchAll() on no results.
authorIlia Alshanetsky <iliaa@php.net>
Thu, 7 Jul 2005 15:14:10 +0000 (15:14 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 7 Jul 2005 15:14:10 +0000 (15:14 +0000)
ext/pdo/pdo_stmt.c

index 1718dba8f63d09f3ffcf68e824b6e841cf669174..b365c96a77162169b7e22fdce09a88a6ac2836e4 100755 (executable)
@@ -1293,8 +1293,7 @@ static PHP_METHOD(PDOStatement, fetchAll)
                }
                if (!do_fetch(stmt, TRUE, data, how, PDO_FETCH_ORI_NEXT, 0, return_all TSRMLS_CC)) {
                        FREE_ZVAL(data);
-                       zval_dtor(return_value);
-                       error = 1;
+                       error = 2;
                }
        }
        if (!error) {
@@ -1320,7 +1319,12 @@ static PHP_METHOD(PDOStatement, fetchAll)
        
        if (error) {
                PDO_HANDLE_STMT_ERR();
-               RETURN_FALSE;
+               if (error != 2) {
+                       RETURN_FALSE;
+               } else { /* on no results, return an empty array */
+                       array_init(return_value);
+                       return;
+               }
        }
 }
 /* }}} */