yohgaki Tue Oct 1 23:16:36 2002 EDT Modified files: /php4/ext/pgsql pgsql.c php_pgsql.h Log: Added pg_data_seek(). pg_result_seek() woudl be better name, but there is mysql_data_seek()... Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.226 php4/ext/pgsql/pgsql.c:1.227 --- php4/ext/pgsql/pgsql.c:1.226 Tue Oct 1 22:41:21 2002 +++ php4/ext/pgsql/pgsql.c Tue Oct 1 23:16:34 2002 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.226 2002/10/02 02:41:21 yohgaki Exp $ */ +/* $Id: pgsql.c,v 1.227 2002/10/02 03:16:34 yohgaki Exp $ */ #include <stdlib.h> @@ -100,6 +100,7 @@ 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) @@ -1415,6 +1416,37 @@ } } /* }}} */ + +/* {{{ 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 Index: php4/ext/pgsql/php_pgsql.h diff -u php4/ext/pgsql/php_pgsql.h:1.50 php4/ext/pgsql/php_pgsql.h:1.51 --- php4/ext/pgsql/php_pgsql.h:1.50 Tue Oct 1 22:41:21 2002 +++ php4/ext/pgsql/php_pgsql.h Tue Oct 1 23:16:35 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pgsql.h,v 1.50 2002/10/02 02:41:21 yohgaki Exp $ */ +/* $Id: php_pgsql.h,v 1.51 2002/10/02 03:16:35 yohgaki Exp $ */ #ifndef PHP_PGSQL_H #define PHP_PGSQL_H @@ -83,6 +83,7 @@ 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);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php