]> granicus.if.org Git - php/commitdiff
Made the row parameter in pg_result_seek() non-optional, the current
authorIlia Alshanetsky <iliaa@php.net>
Tue, 4 Feb 2003 18:34:00 +0000 (18:34 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 4 Feb 2003 18:34:00 +0000 (18:34 +0000)
implementation would result in random behavior if the 2nd argument is not
passed.
Fixed bug #22042 (pg_result_seek() would never seek to the 1st row in the
result due to always seeking to row next to the one requested).
Removed dead code from pg_result_seek().

ext/pgsql/pgsql.c

index e916542f23dc011f7f8a6137a9d4506781d79944..7b85f7df5299c48d787f0a0eb571714c0f13a0e8 100644 (file)
@@ -1437,23 +1437,18 @@ PHP_FUNCTION(pg_result_seek)
        int row;
        pgsql_result_handle *pg_result;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l",
-                                                         &result, &row) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &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->result))
+       if (row < 0 || row >= PQntuples(pg_result->result)) {
                RETURN_FALSE;
+       }
        
        /* seek to offset */
-       pg_result->row = row;
+       pg_result->row = row - 1;
        RETURN_TRUE;
 }
 /* }}} */