cvs: php4 /ext/pgsql pgsql.c php_pgsql.h
| From: | Yasuo Ohgaki | Date: | Sun, 21 Jul 2002 07:25:11 +0000 |
| Subject: | cvs: php4 /ext/pgsql pgsql.c php_pgsql.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-12913@lists.php.net to get a copy of this message | ||
yohgaki Sun Jul 21 03:25:11 2002 EDT
Modified files:
/php4/ext/pgsql pgsql.c php_pgsql.h
Log:
Added pg_fetch_all() that fetch all rows in result.
Useful and faster when there is enough memory.
@Added pg_fetch_all() that fetch all rows in result. (Yasuo)
Index: php4/ext/pgsql/pgsql.c
diff -u php4/ext/pgsql/pgsql.c:1.210 php4/ext/pgsql/pgsql.c:1.211
--- php4/ext/pgsql/pgsql.c:1.210 Sat Jul 20 03:45:01 2002
+++ php4/ext/pgsql/pgsql.c Sun Jul 21 03:25:10 2002
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pgsql.c,v 1.210 2002/07/20 07:45:01 yohgaki Exp $ */
+/* $Id: pgsql.c,v 1.211 2002/07/21 07:25:10 yohgaki Exp $ */
#include <stdlib.h>
@@ -97,6 +97,7 @@
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)
@@ -1352,6 +1353,30 @@
php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_ASSOC);
if (Z_TYPE_P(return_value)==IS_ARRAY) {
object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, Z_ARRVAL_P(return_value));
+ }
+}
+/* }}} */
+
+/* {{{ 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;
}
}
/* }}} */
Index: php4/ext/pgsql/php_pgsql.h
diff -u php4/ext/pgsql/php_pgsql.h:1.46 php4/ext/pgsql/php_pgsql.h:1.47
--- php4/ext/pgsql/php_pgsql.h:1.46 Thu May 9 22:39:37 2002
+++ php4/ext/pgsql/php_pgsql.h Sun Jul 21 03:25:10 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pgsql.h,v 1.46 2002/05/10 02:39:37 edink Exp $ */
+/* $Id: php_pgsql.h,v 1.47 2002/07/21 07:25:10 yohgaki Exp $ */
#ifndef PHP_PGSQL_H
#define PHP_PGSQL_H
@@ -80,6 +80,7 @@
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_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);