From: Yasuo Ohgaki Date: Wed, 2 Oct 2002 03:16:35 +0000 (+0000) Subject: Added pg_data_seek(). X-Git-Tag: MODERN_SYMMETRIC_SESSION_BEHAVIOUR_20021003~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8fdd3c7aedf4fd76089aef11aa136a2760900c0;p=php Added pg_data_seek(). pg_result_seek() woudl be better name, but there is mysql_data_seek()... --- 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);