@@ -1676,22 +1676,32 @@ static int _php_db2_bind_column_helper(stmt_handle *stmt_res TSRMLS_DC)
1676
1676
#endif
1677
1677
case SQL_WCHAR :
1678
1678
case SQL_WVARCHAR :
1679
- case SQL_GRAPHIC :
1680
- case SQL_VARGRAPHIC :
1681
1679
#ifndef PASE /* i5/OS SQL_DBCLOB */
1682
1680
case SQL_DBCLOB :
1683
1681
#endif /* not PASE */
1684
1682
#ifndef PASE /* i5/OS SQL_LONGVARCHAR is SQL_VARCHAR */
1685
1683
case SQL_LONGVARCHAR :
1686
1684
case SQL_WLONGVARCHAR :
1687
1685
case SQL_LONGVARGRAPHIC :
1688
- #else /* i5/OS Until i5 DB2 PTF wide spread - SQL_C_CHAR works (replace orig i5 SqlGetData scheme) */
1689
- target_type = SQL_C_CHAR ;
1690
1686
#endif /* PASE */
1687
+ target_type = SQL_C_CHAR ;
1691
1688
in_length = stmt_res -> column_info [i ].size + 1 ;
1692
1689
row_data -> str_val = (SQLCHAR * )ecalloc (1 , in_length );
1693
1690
1694
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1691
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1692
+ target_type , row_data -> str_val , in_length ,
1693
+ (SQLINTEGER * )(& stmt_res -> row_data [i ].out_length ));
1694
+ if ( rc == SQL_ERROR ) {
1695
+ _php_db2_check_sql_errors ((SQLHSTMT )stmt_res -> hstmt , SQL_HANDLE_STMT , rc , 1 , NULL , -1 , 1 TSRMLS_CC );
1696
+ }
1697
+ break ;
1698
+ case SQL_GRAPHIC :
1699
+ case SQL_VARGRAPHIC :
1700
+ target_type = SQL_C_CHAR ;
1701
+ in_length = (stmt_res -> column_info [i ].size + 1 ) * 2 + 1 ;
1702
+ row_data -> str_val = (SQLCHAR * ) ecalloc (1 , in_length );
1703
+
1704
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT ) (i + 1 ),
1695
1705
target_type , row_data -> str_val , in_length ,
1696
1706
(SQLINTEGER * )(& stmt_res -> row_data [i ].out_length ));
1697
1707
if ( rc == SQL_ERROR ) {
@@ -1709,20 +1719,20 @@ static int _php_db2_bind_column_helper(stmt_handle *stmt_res TSRMLS_DC)
1709
1719
#endif /* PASE */
1710
1720
case SQL_VARBINARY :
1711
1721
if ( stmt_res -> s_bin_mode == DB2_CONVERT ) {
1712
- in_length = 2 * (stmt_res -> column_info [i ].size )+ 1 ;
1722
+ in_length = 2 * (stmt_res -> column_info [i ].size ) + 1 ;
1713
1723
row_data -> str_val = (SQLCHAR * )ecalloc (1 , in_length );
1714
1724
1715
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1725
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1716
1726
SQL_C_CHAR , row_data -> str_val , in_length ,
1717
1727
(SQLINTEGER * )(& stmt_res -> row_data [i ].out_length ));
1718
1728
if ( rc == SQL_ERROR ) {
1719
1729
_php_db2_check_sql_errors ((SQLHSTMT )stmt_res -> hstmt , SQL_HANDLE_STMT , rc , 1 , NULL , -1 , 1 TSRMLS_CC );
1720
1730
}
1721
1731
} else {
1722
- in_length = stmt_res -> column_info [i ].size + 1 ;
1732
+ in_length = stmt_res -> column_info [i ].size + 1 ;
1723
1733
row_data -> str_val = (SQLCHAR * )ecalloc (1 , in_length );
1724
1734
1725
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1735
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1726
1736
SQL_C_DEFAULT , row_data -> str_val , in_length ,
1727
1737
(SQLINTEGER * )(& stmt_res -> row_data [i ].out_length ));
1728
1738
if ( rc == SQL_ERROR ) {
@@ -1750,7 +1760,7 @@ static int _php_db2_bind_column_helper(stmt_handle *stmt_res TSRMLS_DC)
1750
1760
break ;
1751
1761
1752
1762
case SQL_SMALLINT :
1753
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1763
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1754
1764
SQL_C_DEFAULT , & row_data -> s_val , sizeof (row_data -> s_val ),
1755
1765
(SQLINTEGER * )(& stmt_res -> row_data [i ].out_length ));
1756
1766
if ( rc == SQL_ERROR ) {
@@ -1759,7 +1769,7 @@ static int _php_db2_bind_column_helper(stmt_handle *stmt_res TSRMLS_DC)
1759
1769
break ;
1760
1770
1761
1771
case SQL_INTEGER :
1762
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1772
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1763
1773
SQL_C_DEFAULT , & row_data -> i_val , sizeof (row_data -> i_val ),
1764
1774
(SQLINTEGER * )(& stmt_res -> row_data [i ].out_length ));
1765
1775
if ( rc == SQL_ERROR ) {
@@ -1768,15 +1778,15 @@ static int _php_db2_bind_column_helper(stmt_handle *stmt_res TSRMLS_DC)
1768
1778
break ;
1769
1779
1770
1780
case SQL_REAL :
1771
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1781
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1772
1782
SQL_C_FLOAT , & row_data -> r_val , sizeof (row_data -> r_val ),
1773
1783
(SQLINTEGER * )(& stmt_res -> row_data [i ].out_length ));
1774
1784
if ( rc == SQL_ERROR ) {
1775
1785
_php_db2_check_sql_errors ((SQLHSTMT )stmt_res -> hstmt , SQL_HANDLE_STMT , rc , 1 , NULL , -1 , 1 TSRMLS_CC );
1776
1786
}
1777
1787
break ;
1778
1788
case SQL_FLOAT :
1779
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1789
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1780
1790
SQL_C_DEFAULT , & row_data -> f_val , sizeof (row_data -> f_val ),
1781
1791
(SQLINTEGER * )(& stmt_res -> row_data [i ].out_length ));
1782
1792
if ( rc == SQL_ERROR ) {
@@ -1785,7 +1795,7 @@ static int _php_db2_bind_column_helper(stmt_handle *stmt_res TSRMLS_DC)
1785
1795
break ;
1786
1796
1787
1797
case SQL_DOUBLE :
1788
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1798
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1789
1799
SQL_C_DEFAULT , & row_data -> d_val , sizeof (row_data -> d_val ),
1790
1800
(SQLINTEGER * )(& stmt_res -> row_data [i ].out_length ));
1791
1801
if ( rc == SQL_ERROR ) {
@@ -1798,7 +1808,7 @@ static int _php_db2_bind_column_helper(stmt_handle *stmt_res TSRMLS_DC)
1798
1808
in_length = stmt_res -> column_info [i ].size +
1799
1809
stmt_res -> column_info [i ].scale + 2 + 1 ;
1800
1810
row_data -> str_val = (SQLCHAR * )ecalloc (1 , in_length );
1801
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1811
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1802
1812
SQL_C_CHAR , row_data -> str_val , in_length ,
1803
1813
(SQLINTEGER * )(& stmt_res -> row_data [i ].out_length ));
1804
1814
if ( rc == SQL_ERROR ) {
@@ -1810,7 +1820,7 @@ static int _php_db2_bind_column_helper(stmt_handle *stmt_res TSRMLS_DC)
1810
1820
stmt_res -> row_data [i ].out_length = 0 ;
1811
1821
stmt_res -> column_info [i ].loc_type = SQL_CLOB_LOCATOR ;
1812
1822
stmt_res -> column_info [i ].loc_ind = 0 ;
1813
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1823
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1814
1824
stmt_res -> column_info [i ].loc_type , & stmt_res -> column_info [i ].lob_loc , 4 ,
1815
1825
& stmt_res -> column_info [i ].loc_ind );
1816
1826
if ( rc == SQL_ERROR ) {
@@ -1821,7 +1831,7 @@ static int _php_db2_bind_column_helper(stmt_handle *stmt_res TSRMLS_DC)
1821
1831
stmt_res -> row_data [i ].out_length = 0 ;
1822
1832
stmt_res -> column_info [i ].loc_type = SQL_BLOB_LOCATOR ;
1823
1833
stmt_res -> column_info [i ].loc_ind = 0 ;
1824
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1834
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1825
1835
stmt_res -> column_info [i ].loc_type , & stmt_res -> column_info [i ].lob_loc , 4 ,
1826
1836
& stmt_res -> column_info [i ].loc_ind );
1827
1837
if ( rc == SQL_ERROR ) {
@@ -1833,7 +1843,7 @@ static int _php_db2_bind_column_helper(stmt_handle *stmt_res TSRMLS_DC)
1833
1843
stmt_res -> row_data [i ].out_length = 0 ;
1834
1844
stmt_res -> column_info [i ].loc_type = SQL_DBCLOB_LOCATOR ;
1835
1845
stmt_res -> column_info [i ].loc_ind = 0 ;
1836
- rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1846
+ rc = SQLBindCol ((SQLHSTMT )stmt_res -> hstmt , (SQLUSMALLINT )(i + 1 ),
1837
1847
stmt_res -> column_info [i ].loc_type , & stmt_res -> column_info [i ].lob_loc , 4 ,
1838
1848
& stmt_res -> column_info [i ].loc_ind );
1839
1849
if ( rc == SQL_ERROR ) {
@@ -2492,9 +2502,9 @@ PHP_FUNCTION(db2_bind_param)
2492
2502
}
2493
2503
/* }}} */
2494
2504
2495
- /* {{{ static int _php_db2_close_helper( INTERNAL_FUNCTION_PARAMETERS )
2505
+ /* {{{ static void _php_db2_close_helper( INTERNAL_FUNCTION_PARAMETERS )
2496
2506
*/
2497
- static int _php_db2_close_helper ( INTERNAL_FUNCTION_PARAMETERS , int endpconnect )
2507
+ static void _php_db2_close_helper ( INTERNAL_FUNCTION_PARAMETERS , int endpconnect )
2498
2508
{
2499
2509
int argc = ZEND_NUM_ARGS ();
2500
2510
int connection_id = -1 ;
@@ -2512,7 +2522,9 @@ static int _php_db2_close_helper( INTERNAL_FUNCTION_PARAMETERS, int endpconnect
2512
2522
"Connection Resource" , le_conn_struct , le_pconn_struct );
2513
2523
2514
2524
#ifdef PASE /* db2_pclose - last ditch persistent close */
2515
- if (endpconnect ) conn_res -> flag_pconnect = 0 ;
2525
+ if (endpconnect ) {
2526
+ conn_res -> flag_pconnect = 0 ;
2527
+ }
2516
2528
#endif /* PASE */
2517
2529
2518
2530
if ( conn_res -> handle_active && !conn_res -> flag_pconnect ) {
@@ -2559,7 +2571,7 @@ static int _php_db2_close_helper( INTERNAL_FUNCTION_PARAMETERS, int endpconnect
2559
2571
Closes a database connection */
2560
2572
PHP_FUNCTION (db2_close )
2561
2573
{
2562
- return _php_db2_close_helper (INTERNAL_FUNCTION_PARAM_PASSTHRU , 0 );
2574
+ _php_db2_close_helper (INTERNAL_FUNCTION_PARAM_PASSTHRU , 0 );
2563
2575
}
2564
2576
/* }}} */
2565
2577
@@ -2568,7 +2580,7 @@ PHP_FUNCTION(db2_close)
2568
2580
Closes a database connection */
2569
2581
PHP_FUNCTION (db2_pclose )
2570
2582
{
2571
- return _php_db2_close_helper (INTERNAL_FUNCTION_PARAM_PASSTHRU , 1 );
2583
+ _php_db2_close_helper (INTERNAL_FUNCTION_PARAM_PASSTHRU , 1 );
2572
2584
}
2573
2585
/* }}} */
2574
2586
#endif /* PASE */
@@ -3963,12 +3975,16 @@ PHP_FUNCTION(db2_execute)
3963
3975
curr_ptr = curr_ptr -> next ;
3964
3976
3965
3977
/* Free Values */
3966
- if ( Z_TYPE_P (prev_ptr -> value ) == IS_STRING ) {
3967
- efree ((prev_ptr -> value )-> value .str .val );
3968
- }
3978
+ if (prev_ptr -> value != NULL ) {
3979
+ if ( Z_TYPE_P (prev_ptr -> value ) == IS_STRING ) {
3980
+ if ((prev_ptr -> value )-> value .str .val != NULL || (prev_ptr -> value )-> value .str .len != 0 ) {
3981
+ efree ((prev_ptr -> value )-> value .str .val );
3982
+ }
3983
+ }
3969
3984
3970
- if ( prev_ptr -> param_type != DB2_PARAM_OUT && prev_ptr -> param_type != DB2_PARAM_INOUT ){
3971
- efree (prev_ptr -> value );
3985
+ if ( prev_ptr -> param_type != DB2_PARAM_OUT && prev_ptr -> param_type != DB2_PARAM_INOUT ){
3986
+ efree (prev_ptr -> value );
3987
+ }
3972
3988
}
3973
3989
efree (prev_ptr );
3974
3990
@@ -6376,11 +6392,7 @@ PHP_FUNCTION(db2_last_insert_id)
6376
6392
}
6377
6393
6378
6394
/* Selecting last insert ID from current connection resource. */
6379
- #ifdef PASE /* i5/OS no shortcut */
6380
6395
sql = "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1" ;
6381
- #else
6382
- sql = "VALUES IDENTITY_VAL_LOCAL()" ;
6383
- #endif
6384
6396
rc = SQLExecDirect (hstmt , (SQLCHAR * ) sql , strlen (sql ));
6385
6397
if ( rc == SQL_ERROR ) {
6386
6398
_php_db2_check_sql_errors ((SQLHDBC )conn_res -> hdbc , SQL_HANDLE_DBC , rc , 1 , NULL , -1 , 1 TSRMLS_CC );
0 commit comments