summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYasuo Ohgaki <yohgaki@php.net>2002-10-02 03:16:35 +0000
committerYasuo Ohgaki <yohgaki@php.net>2002-10-02 03:16:35 +0000
commitb8fdd3c7aedf4fd76089aef11aa136a2760900c0 (patch)
treeb3b66fb9c1a72f207024cbd0fd4c8c6d39151047
parent2728440fdcaf73f453cac01958e4b07dd5cd987c (diff)
downloadphp-git-b8fdd3c7aedf4fd76089aef11aa136a2760900c0.tar.gz
Added pg_data_seek().
pg_result_seek() woudl be better name, but there is mysql_data_seek()...
-rw-r--r--ext/pgsql/pgsql.c32
-rw-r--r--ext/pgsql/php_pgsql.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 0e7cd398ef..d24876594a 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -100,6 +100,7 @@ function_entry pgsql_functions[] = {
PHP_FE(pg_fetch_array, NULL)
PHP_FE(pg_fetch_object, NULL)
PHP_FE(pg_fetch_all, NULL)
+ PHP_FE(pg_data_seek, NULL)
PHP_FE(pg_affected_rows,NULL)
PHP_FE(pg_get_result, NULL)
PHP_FE(pg_result_status,NULL)
@@ -1416,6 +1417,37 @@ PHP_FUNCTION(pg_fetch_all)
}
/* }}} */
+/* {{{ proto mixed pg_data_seek(resource result, int offset)
+ Set internal row offset */
+PHP_FUNCTION(pg_data_seek)
+{
+ zval *result;
+ int row;
+ PGresult *pgsql_result;
+ pgsql_result_handle *pg_result;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l",
+ &result, &row) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, &result, -1, "PostgreSQL result", le_result);
+
+ /* Let see if we are better to have another function for this */
+ /* if offset is omitted, return current position */
+/* if (ZEND_NUM_ARGS() == 1) */
+/* RETURN_LONG(pg_result->row); */
+
+ if (row < 0 || row >= PQntuples(pg_result))
+ RETURN_FALSE;
+
+ /* seek to offset */
+ pg_result->row = row;
+ RETURN_TRUE;
+}
+/* }}} */
+
+
#define PHP_PG_DATA_LENGTH 1
#define PHP_PG_DATA_ISNULL 2
diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h
index 11187ece5d..4b00fc3eed 100644
--- a/ext/pgsql/php_pgsql.h
+++ b/ext/pgsql/php_pgsql.h
@@ -83,6 +83,7 @@ PHP_FUNCTION(pg_fetch_object);
PHP_FUNCTION(pg_fetch_result);
PHP_FUNCTION(pg_fetch_row);
PHP_FUNCTION(pg_fetch_all);
+PHP_FUNCTION(pg_data_seek);
PHP_FUNCTION(pg_affected_rows);
PHP_FUNCTION(pg_get_result);
PHP_FUNCTION(pg_result_status);