@@ -787,6 +787,11 @@ void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
787
787
RETURN_THROWS ();
788
788
}
789
789
790
+ if (pv_num < 1 ) {
791
+ zend_argument_value_error (2 , "must be greater than or equal to 1" );
792
+ RETURN_THROWS ();
793
+ }
794
+
790
795
if (result -> numcols == 0 ) {
791
796
php_error_docref (NULL , E_WARNING , "No tuples available at this result index" );
792
797
RETURN_FALSE ;
@@ -797,11 +802,6 @@ void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
797
802
RETURN_FALSE ;
798
803
}
799
804
800
- if (pv_num < 1 ) {
801
- php_error_docref (NULL , E_WARNING , "Field numbering starts at 1" );
802
- RETURN_FALSE ;
803
- }
804
-
805
805
PHP_ODBC_SQLCOLATTRIBUTE (result -> stmt , (SQLUSMALLINT )pv_num , (SQLUSMALLINT ) (type ?SQL_COLUMN_SCALE :SQL_COLUMN_PRECISION ), NULL , 0 , NULL , & len );
806
806
807
807
RETURN_LONG (len );
@@ -963,7 +963,8 @@ PHP_FUNCTION(odbc_prepare)
963
963
/* {{{ Execute a prepared statement */
964
964
PHP_FUNCTION (odbc_execute )
965
965
{
966
- zval * pv_res , * pv_param_arr , * tmp ;
966
+ zval * pv_res , * tmp ;
967
+ HashTable * pv_param_ht ;
967
968
typedef struct params_t {
968
969
SQLLEN vallen ;
969
970
int fp ;
@@ -976,7 +977,7 @@ PHP_FUNCTION(odbc_execute)
976
977
int numArgs = ZEND_NUM_ARGS (), i , ne ;
977
978
RETCODE rc ;
978
979
979
- if (zend_parse_parameters (numArgs , "r|a " , & pv_res , & pv_param_arr ) == FAILURE ) {
980
+ if (zend_parse_parameters (numArgs , "r|h " , & pv_res , & pv_param_ht ) == FAILURE ) {
980
981
RETURN_THROWS ();
981
982
}
982
983
@@ -991,19 +992,19 @@ PHP_FUNCTION(odbc_execute)
991
992
}
992
993
993
994
if (result -> numparams > 0 ) {
994
- if ((ne = zend_hash_num_elements (Z_ARRVAL_P ( pv_param_arr ) )) < result -> numparams ) {
995
+ if ((ne = zend_hash_num_elements (pv_param_ht )) < result -> numparams ) {
995
996
php_error_docref (NULL , E_WARNING ,"Not enough parameters (%d should be %d) given" , ne , result -> numparams );
996
997
RETURN_FALSE ;
997
998
}
998
999
999
- zend_hash_internal_pointer_reset (Z_ARRVAL_P ( pv_param_arr ) );
1000
+ zend_hash_internal_pointer_reset (pv_param_ht );
1000
1001
params = (params_t * )safe_emalloc (sizeof (params_t ), result -> numparams , 0 );
1001
1002
for (i = 0 ; i < result -> numparams ; i ++ ) {
1002
1003
params [i ].fp = -1 ;
1003
1004
}
1004
1005
1005
1006
for (i = 1 ; i <= result -> numparams ; i ++ ) {
1006
- if ((tmp = zend_hash_get_current_data (Z_ARRVAL_P ( pv_param_arr ) )) == NULL ) {
1007
+ if ((tmp = zend_hash_get_current_data (pv_param_ht )) == NULL ) {
1007
1008
php_error_docref (NULL , E_WARNING ,"Error getting parameter" );
1008
1009
SQLFreeStmt (result -> stmt ,SQL_RESET_PARAMS );
1009
1010
for (i = 0 ; i < result -> numparams ; i ++ ) {
@@ -1104,7 +1105,7 @@ PHP_FUNCTION(odbc_execute)
1104
1105
efree (params );
1105
1106
RETURN_FALSE ;
1106
1107
}
1107
- zend_hash_move_forward (Z_ARRVAL_P ( pv_param_arr ) );
1108
+ zend_hash_move_forward (pv_param_ht );
1108
1109
}
1109
1110
}
1110
1111
/* Close cursor, needed for doing multiple selects */
@@ -1246,8 +1247,8 @@ PHP_FUNCTION(odbc_data_source)
1246
1247
fetch_type = (SQLSMALLINT ) zv_fetch_type ;
1247
1248
1248
1249
if (!(fetch_type == SQL_FETCH_FIRST || fetch_type == SQL_FETCH_NEXT )) {
1249
- php_error_docref ( NULL , E_WARNING , "Invalid fetch type (%d)" , fetch_type );
1250
- RETURN_FALSE ;
1250
+ zend_argument_value_error ( 2 , "must be SQL_FETCH_FIRST or SQL_FETCH_NEXT" );
1251
+ RETURN_THROWS ()
1251
1252
}
1252
1253
1253
1254
if (!(conn = (odbc_connection * )zend_fetch_resource2 (Z_RES_P (zv_conn ), "ODBC-Link" , le_conn , le_pconn ))) {
@@ -2209,8 +2210,9 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
2209
2210
cur_opt == SQL_CUR_USE_ODBC ||
2210
2211
cur_opt == SQL_CUR_USE_DRIVER ||
2211
2212
cur_opt == SQL_CUR_DEFAULT ) ) {
2212
- php_error_docref (NULL , E_WARNING , "Invalid Cursor type (%d)" , cur_opt );
2213
- RETURN_FALSE ;
2213
+ zend_argument_value_error (4 , "must be one of SQL_CUR_USE_IF_NEEDED, "
2214
+ "SQL_CUR_USE_ODBC, or SQL_CUR_USE_DRIVER" );
2215
+ RETURN_THROWS ();
2214
2216
}
2215
2217
}
2216
2218
@@ -2483,6 +2485,11 @@ PHP_FUNCTION(odbc_field_name)
2483
2485
RETURN_THROWS ();
2484
2486
}
2485
2487
2488
+ if (pv_num < 1 ) {
2489
+ zend_argument_value_error (2 , "must be greater than or equal to 1" );
2490
+ RETURN_THROWS ();
2491
+ }
2492
+
2486
2493
if (result -> numcols == 0 ) {
2487
2494
php_error_docref (NULL , E_WARNING , "No tuples available at this result index" );
2488
2495
RETURN_FALSE ;
@@ -2493,11 +2500,6 @@ PHP_FUNCTION(odbc_field_name)
2493
2500
RETURN_FALSE ;
2494
2501
}
2495
2502
2496
- if (pv_num < 1 ) {
2497
- php_error_docref (NULL , E_WARNING , "Field numbering starts at 1" );
2498
- RETURN_FALSE ;
2499
- }
2500
-
2501
2503
RETURN_STRING (result -> values [pv_num - 1 ].name );
2502
2504
}
2503
2505
/* }}} */
@@ -2519,6 +2521,11 @@ PHP_FUNCTION(odbc_field_type)
2519
2521
RETURN_THROWS ();
2520
2522
}
2521
2523
2524
+ if (pv_num < 1 ) {
2525
+ zend_argument_value_error (2 , "must be greater than or equal to 1" );
2526
+ RETURN_THROWS ();
2527
+ }
2528
+
2522
2529
if (result -> numcols == 0 ) {
2523
2530
php_error_docref (NULL , E_WARNING , "No tuples available at this result index" );
2524
2531
RETURN_FALSE ;
@@ -2529,11 +2536,6 @@ PHP_FUNCTION(odbc_field_type)
2529
2536
RETURN_FALSE ;
2530
2537
}
2531
2538
2532
- if (pv_num < 1 ) {
2533
- php_error_docref (NULL , E_WARNING , "Field numbering starts at 1" );
2534
- RETURN_FALSE ;
2535
- }
2536
-
2537
2539
PHP_ODBC_SQLCOLATTRIBUTE (result -> stmt , (SQLUSMALLINT )pv_num , SQL_COLUMN_TYPE_NAME , tmp , 31 , & tmplen , NULL );
2538
2540
RETURN_STRING (tmp );
2539
2541
}
@@ -2733,9 +2735,8 @@ PHP_FUNCTION(odbc_setoption)
2733
2735
}
2734
2736
break ;
2735
2737
default :
2736
- php_error_docref (NULL , E_WARNING , "Unknown option type" );
2737
- RETURN_FALSE ;
2738
- break ;
2738
+ zend_argument_value_error (2 , "must be 1 for SQLSetConnectOption(), or 2 for SQLSetStmtOption()" );
2739
+ RETURN_THROWS ();
2739
2740
}
2740
2741
2741
2742
RETURN_TRUE ;
0 commit comments