@@ -1120,18 +1120,13 @@ PHP_FUNCTION(pg_query_params)
1120
1120
if (Z_TYPE_P (tmp ) == IS_NULL ) {
1121
1121
params [i ] = NULL ;
1122
1122
} else {
1123
- zval tmp_val ;
1124
-
1125
- ZVAL_COPY (& tmp_val , tmp );
1126
- convert_to_string (& tmp_val );
1127
- if (Z_TYPE (tmp_val ) != IS_STRING ) {
1128
- php_error_docref (NULL , E_WARNING ,"Error converting parameter" );
1129
- zval_ptr_dtor (& tmp_val );
1123
+ zend_string * param_str = zval_try_get_string (tmp );
1124
+ if (!param_str ) {
1130
1125
_php_pgsql_free_params (params , num_params );
1131
- RETURN_FALSE ;
1126
+ RETURN_THROWS () ;
1132
1127
}
1133
- params [i ] = estrndup (Z_STRVAL ( tmp_val ), Z_STRLEN ( tmp_val ));
1134
- zval_ptr_dtor ( & tmp_val );
1128
+ params [i ] = estrndup (ZSTR_VAL ( param_str ), ZSTR_LEN ( param_str ));
1129
+ zend_string_release ( param_str );
1135
1130
}
1136
1131
i ++ ;
1137
1132
} ZEND_HASH_FOREACH_END ();
@@ -1796,39 +1791,34 @@ PHP_FUNCTION(pg_fetch_result)
1796
1791
/* {{{ void php_pgsql_fetch_hash */
1797
1792
static void php_pgsql_fetch_hash (INTERNAL_FUNCTION_PARAMETERS , zend_long result_type , int into_object )
1798
1793
{
1799
- zval * result , * zrow = NULL ;
1794
+ zval * result ;
1800
1795
PGresult * pgsql_result ;
1801
1796
pgsql_result_handle * pg_result ;
1802
- int i , num_fields , pgsql_row , use_row ;
1803
- zend_long row = -1 ;
1797
+ int i , num_fields , pgsql_row ;
1798
+ zend_long row ;
1799
+ bool row_is_null = 1 ;
1804
1800
char * field_name ;
1805
1801
zval * ctor_params = NULL ;
1806
1802
zend_class_entry * ce = NULL ;
1807
1803
1808
1804
if (into_object ) {
1809
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "r|z !Cz" , & result , & zrow , & ce , & ctor_params ) == FAILURE ) {
1805
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "r|l !Cz" , & result , & row , & row_is_null , & ce , & ctor_params ) == FAILURE ) {
1810
1806
RETURN_THROWS ();
1811
1807
}
1812
1808
if (!ce ) {
1813
1809
ce = zend_standard_class_def ;
1814
1810
}
1815
1811
result_type = PGSQL_ASSOC ;
1816
1812
} else {
1817
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "r|z !l" , & result , & zrow , & result_type ) == FAILURE ) {
1813
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "r|l !l" , & result , & row , & row_is_null , & result_type ) == FAILURE ) {
1818
1814
RETURN_THROWS ();
1819
1815
}
1820
1816
}
1821
- if (zrow == NULL ) {
1822
- row = -1 ;
1823
- } else {
1824
- convert_to_long (zrow );
1825
- row = Z_LVAL_P (zrow );
1826
- if (row < 0 ) {
1827
- php_error_docref (NULL , E_WARNING , "The row parameter must be greater or equal to zero" );
1828
- RETURN_FALSE ;
1829
- }
1817
+
1818
+ if (!row_is_null && row < 0 ) {
1819
+ php_error_docref (NULL , E_WARNING , "The row parameter must be greater or equal to zero" );
1820
+ RETURN_FALSE ;
1830
1821
}
1831
- use_row = ZEND_NUM_ARGS () > 1 && row != -1 ;
1832
1822
1833
1823
if (!(result_type & PGSQL_BOTH )) {
1834
1824
php_error_docref (NULL , E_WARNING , "Invalid result type" );
@@ -1841,7 +1831,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_
1841
1831
1842
1832
pgsql_result = pg_result -> result ;
1843
1833
1844
- if (use_row ) {
1834
+ if (! row_is_null ) {
1845
1835
if (row < 0 || row >= PQntuples (pgsql_result )) {
1846
1836
php_error_docref (NULL , E_WARNING , "Unable to jump to row " ZEND_LONG_FMT " on PostgreSQL result index " ZEND_LONG_FMT ,
1847
1837
row , Z_LVAL_P (result ));
0 commit comments