]> granicus.if.org Git - php/commitdiff
Added pg_fetch_all() that fetch all rows in result.
authorYasuo Ohgaki <yohgaki@php.net>
Sun, 21 Jul 2002 07:25:10 +0000 (07:25 +0000)
committerYasuo Ohgaki <yohgaki@php.net>
Sun, 21 Jul 2002 07:25:10 +0000 (07:25 +0000)
Useful and faster when there is enough memory.
@Added pg_fetch_all() that fetch all rows in result. (Yasuo)

ext/pgsql/pgsql.c
ext/pgsql/php_pgsql.h

index 32fe5132aee76ba36a8cdce616542c884b6e0c7a..1c3970128231b32010263e78bc28de2413ed672d 100644 (file)
@@ -97,6 +97,7 @@ function_entry pgsql_functions[] = {
        PHP_FE(pg_fetch_row,    NULL)
        PHP_FE(pg_fetch_array,  NULL)
        PHP_FE(pg_fetch_object, NULL)
+       PHP_FE(pg_fetch_all,    NULL)
        PHP_FE(pg_affected_rows,NULL)
        PHP_FE(pg_get_result,   NULL)
        PHP_FE(pg_result_status,NULL)
@@ -1356,6 +1357,30 @@ PHP_FUNCTION(pg_fetch_object)
 }
 /* }}} */
 
+/* {{{ proto array pg_fetch_all(resource result)
+   Fetch all rows into array */
+PHP_FUNCTION(pg_fetch_all)
+{
+       zval *result;
+       PGresult *pgsql_result;
+       pgsql_result_handle *pg_result;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r",
+                                                         &result) == FAILURE) {
+               return;
+       }
+
+       ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, &result, -1, "PostgreSQL result", le_result);
+
+       pgsql_result = pg_result->result;
+       array_init(return_value);
+       if (php_pgsql_result2array(pgsql_result, return_value TSRMLS_CC) == FAILURE) {
+               zval_dtor(return_value);
+               RETURN_FALSE;
+       }
+}
+/* }}} */
+
 #define PHP_PG_DATA_LENGTH 1
 #define PHP_PG_DATA_ISNULL 2
 
index 4d0bfd749b86486454e4703ea9683a9ce4e3c7ad..a18c7b598dee99ee78988c61c83cc31114aee46c 100644 (file)
@@ -80,6 +80,7 @@ PHP_FUNCTION(pg_fetch_array);
 PHP_FUNCTION(pg_fetch_object);
 PHP_FUNCTION(pg_fetch_result);
 PHP_FUNCTION(pg_fetch_row);
+PHP_FUNCTION(pg_fetch_all);
 PHP_FUNCTION(pg_affected_rows);
 PHP_FUNCTION(pg_get_result);
 PHP_FUNCTION(pg_result_status);
@@ -153,6 +154,7 @@ PHPAPI int php_pgsql_insert(PGconn *pg_link, const char *table, zval *values, ul
 PHPAPI int php_pgsql_update(PGconn *pg_link, const char *table, zval *values, zval *ids, ulong opt , char **sql TSRMLS_DC);
 PHPAPI int php_pgsql_delete(PGconn *pg_link, const char *table, zval *ids, ulong opt, char **sql TSRMLS_DC);
 PHPAPI int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids, zval *ret_array, ulong opt, char **sql  TSRMLS_DC);
+PHPAPI int php_pgsql_result2array(PGresult *pg_result, zval *ret_array TSRMLS_DC);
 
 /* internal functions */
 static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent);