cvs: php4 /ext/pgsql pgsql.c

From: Date: Mon, 15 Jul 2002 10:04:01 +0000
Subject: cvs: php4 /ext/pgsql pgsql.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12842@lists.php.net to get a copy of this message
yohgaki Mon Jul 15 06:04:01 2002 EDT Modified files: /php4/ext/pgsql pgsql.c Log: Clean up code a little (Remove a use of magic number) Change/add appropriate comments. Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.202 php4/ext/pgsql/pgsql.c:1.203 --- php4/ext/pgsql/pgsql.c:1.202 Thu Jul 11 11:45:35 2002 +++ php4/ext/pgsql/pgsql.c Mon Jul 15 06:04:01 2002 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.202 2002/07/11 15:45:35 hirokawa Exp $ */ +/* $Id: pgsql.c,v 1.203 2002/07/15 10:04:01 yohgaki Exp $ */ #include <stdlib.h> @@ -1232,23 +1232,17 @@ uint element_len; switch (ZEND_NUM_ARGS()) { - case 1: + case 1: /* pg_fetch_*(result) */ if (zend_get_parameters_ex(1, &result) == FAILURE) { RETURN_FALSE; } - if (!result_type) { - result_type = PGSQL_BOTH; - } break; - case 2: + case 2: /* pg_fetch_*(result, row) */ if (zend_get_parameters_ex(2, &result, &row) == FAILURE) { RETURN_FALSE; } - if (!result_type) { - result_type = PGSQL_BOTH; - } break; - case 3: + case 3: /* pg_fetch_*(result, row, result_type) */ if (zend_get_parameters_ex(3, &result, &row, &arg3) == FAILURE) { RETURN_FALSE; } @@ -1260,6 +1254,12 @@ break; } + if (!(result_type & PGSQL_BOTH)) { + php_error(E_WARNING, "%s(): invalid result type", + get_active_function_name(TSRMLS_C)); + RETURN_FALSE; + } + ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result); pgsql_result = pg_result->result; @@ -1281,7 +1281,7 @@ RETURN_FALSE; } } else { - /* If 2nd param is NULL, ignore it and use the normal way of accessing the next row */ + /* If 2nd param is NULL, use internal row counter to access next row */ pg_result->row++; pgsql_row = pg_result->row; if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) { @@ -1329,7 +1329,7 @@ } /* }}} */ -/* {{{ proto array pg_fetch_row(resource result [, int row]) +/* {{{ proto array pg_fetch_row(resource result [, int row [, int result_type]]) Get a row as an enumerated array */ PHP_FUNCTION(pg_fetch_row) { @@ -1341,7 +1341,7 @@ Fetch a row as an array */ PHP_FUNCTION(pg_fetch_array) { - php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); + php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_BOTH); } /* }}} */

« previous php.cvs (#12842) next »