@@ -885,9 +885,7 @@ PHP_FUNCTION(odbc_prepare)
885
885
odbc_result * result = NULL ;
886
886
RETCODE rc ;
887
887
int i ;
888
- #ifdef HAVE_SQL_EXTENDED_FETCH
889
888
SQLUINTEGER scrollopts ;
890
- #endif
891
889
892
890
if (zend_parse_parameters (ZEND_NUM_ARGS (), "Os" , & pv_conn , odbc_connection_ce , & query , & query_len ) == FAILURE ) {
893
891
RETURN_THROWS ();
@@ -915,9 +913,6 @@ PHP_FUNCTION(odbc_prepare)
915
913
RETURN_FALSE ;
916
914
}
917
915
918
- #ifdef HAVE_SQL_EXTENDED_FETCH
919
- /* Solid doesn't have ExtendedFetch, if DriverManager is used, get Info,
920
- whether Driver supports ExtendedFetch */
921
916
rc = SQLGetInfo (conn -> hdbc , SQL_FETCH_DIRECTION , (void * ) & scrollopts , sizeof (scrollopts ), NULL );
922
917
if (rc == SQL_SUCCESS ) {
923
918
if ((result -> fetch_abs = (scrollopts & SQL_FD_FETCH_ABSOLUTE ))) {
@@ -929,7 +924,6 @@ PHP_FUNCTION(odbc_prepare)
929
924
} else {
930
925
result -> fetch_abs = 0 ;
931
926
}
932
- #endif
933
927
934
928
rc = SQLPrepare (result -> stmt , (SQLCHAR * ) query , SQL_NTS );
935
929
switch (rc ) {
@@ -1272,9 +1266,7 @@ PHP_FUNCTION(odbc_exec)
1272
1266
size_t query_len ;
1273
1267
odbc_result * result = NULL ;
1274
1268
RETCODE rc ;
1275
- #ifdef HAVE_SQL_EXTENDED_FETCH
1276
1269
SQLUINTEGER scrollopts ;
1277
- #endif
1278
1270
1279
1271
if (zend_parse_parameters (ZEND_NUM_ARGS (), "Os" , & pv_conn , odbc_connection_ce , & query , & query_len ) == FAILURE ) {
1280
1272
RETURN_THROWS ();
@@ -1299,9 +1291,6 @@ PHP_FUNCTION(odbc_exec)
1299
1291
RETURN_FALSE ;
1300
1292
}
1301
1293
1302
- #ifdef HAVE_SQL_EXTENDED_FETCH
1303
- /* Solid doesn't have ExtendedFetch, if DriverManager is used, get Info,
1304
- whether Driver supports ExtendedFetch */
1305
1294
rc = SQLGetInfo (conn -> hdbc , SQL_FETCH_DIRECTION , (void * ) & scrollopts , sizeof (scrollopts ), NULL );
1306
1295
if (rc == SQL_SUCCESS ) {
1307
1296
if ((result -> fetch_abs = (scrollopts & SQL_FD_FETCH_ABSOLUTE ))) {
@@ -1313,7 +1302,6 @@ PHP_FUNCTION(odbc_exec)
1313
1302
} else {
1314
1303
result -> fetch_abs = 0 ;
1315
1304
}
1316
- #endif
1317
1305
1318
1306
rc = SQLExecDirect (result -> stmt , (SQLCHAR * ) query , SQL_NTS );
1319
1307
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO && rc != SQL_NO_DATA_FOUND ) {
@@ -1356,10 +1344,8 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
1356
1344
zend_long pv_row = 0 ;
1357
1345
bool pv_row_is_null = true;
1358
1346
zval * pv_res , tmp ;
1359
- #ifdef HAVE_SQL_EXTENDED_FETCH
1360
1347
SQLULEN crow ;
1361
1348
SQLUSMALLINT RowStatus [1 ];
1362
- #endif
1363
1349
1364
1350
if (zend_parse_parameters (ZEND_NUM_ARGS (), "O|l!" , & pv_res , odbc_result_ce , & pv_row , & pv_row_is_null ) == FAILURE ) {
1365
1351
RETURN_THROWS ();
@@ -1370,46 +1356,33 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
1370
1356
1371
1357
/* TODO deprecate $row argument values less than 1 after PHP 8.4 */
1372
1358
1373
- #ifndef HAVE_SQL_EXTENDED_FETCH
1374
- if (!pv_row_is_null && pv_row > 0 ) {
1375
- php_error_docref (NULL , E_WARNING , "Extended fetch functionality is not available, argument #3 ($row) is ignored" );
1376
- }
1377
- #endif
1378
-
1379
1359
if (result -> numcols == 0 ) {
1380
1360
php_error_docref (NULL , E_WARNING , "No tuples available at this result index" );
1381
1361
RETURN_FALSE ;
1382
1362
}
1383
1363
1384
- #ifdef HAVE_SQL_EXTENDED_FETCH
1385
1364
if (result -> fetch_abs ) {
1386
1365
if (!pv_row_is_null && pv_row > 0 ) {
1387
1366
rc = SQLExtendedFetch (result -> stmt ,SQL_FETCH_ABSOLUTE ,(SQLLEN )pv_row ,& crow ,RowStatus );
1388
1367
} else {
1389
1368
rc = SQLExtendedFetch (result -> stmt ,SQL_FETCH_NEXT ,1 ,& crow ,RowStatus );
1390
1369
}
1391
- } else
1392
- #endif
1393
- rc = SQLFetch ( result -> stmt );
1370
+ } else {
1371
+ rc = SQLFetch ( result -> stmt );
1372
+ }
1394
1373
1395
1374
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO ) {
1396
1375
if (rc == SQL_ERROR ) {
1397
- #ifdef HAVE_SQL_EXTENDED_FETCH
1398
1376
odbc_sql_error (result -> conn_ptr , result -> stmt , "SQLExtendedFetch" );
1399
- #else
1400
- odbc_sql_error (result -> conn_ptr , result -> stmt , "SQLFetch" );
1401
- #endif
1402
1377
}
1403
1378
RETURN_FALSE ;
1404
1379
}
1405
1380
1406
1381
array_init (return_value );
1407
1382
1408
- #ifdef HAVE_SQL_EXTENDED_FETCH
1409
1383
if (!pv_row_is_null && pv_row > 0 && result -> fetch_abs )
1410
1384
result -> fetched = (SQLLEN )pv_row ;
1411
1385
else
1412
- #endif
1413
1386
result -> fetched ++ ;
1414
1387
1415
1388
for (i = 0 ; i < result -> numcols ; i ++ ) {
@@ -1523,10 +1496,8 @@ PHP_FUNCTION(odbc_fetch_into)
1523
1496
zval * pv_res , * pv_res_arr , tmp ;
1524
1497
zend_long pv_row = 0 ;
1525
1498
bool pv_row_is_null = true;
1526
- #ifdef HAVE_SQL_EXTENDED_FETCH
1527
1499
SQLULEN crow ;
1528
1500
SQLUSMALLINT RowStatus [1 ];
1529
- #endif /* HAVE_SQL_EXTENDED_FETCH */
1530
1501
1531
1502
if (zend_parse_parameters (ZEND_NUM_ARGS (), "Oz|l!" , & pv_res , odbc_result_ce , & pv_res_arr , & pv_row , & pv_row_is_null ) == FAILURE ) {
1532
1503
RETURN_THROWS ();
@@ -1537,12 +1508,6 @@ PHP_FUNCTION(odbc_fetch_into)
1537
1508
1538
1509
/* TODO deprecate $row argument values less than 1 after PHP 8.4 */
1539
1510
1540
- #ifndef HAVE_SQL_EXTENDED_FETCH
1541
- if (!pv_row_is_null && pv_row > 0 ) {
1542
- php_error_docref (NULL , E_WARNING , "Extended fetch functionality is not available, argument #3 ($row) is ignored" );
1543
- }
1544
- #endif
1545
-
1546
1511
if (result -> numcols == 0 ) {
1547
1512
php_error_docref (NULL , E_WARNING , "No tuples available at this result index" );
1548
1513
RETURN_FALSE ;
@@ -1553,33 +1518,26 @@ PHP_FUNCTION(odbc_fetch_into)
1553
1518
RETURN_THROWS ();
1554
1519
}
1555
1520
1556
- #ifdef HAVE_SQL_EXTENDED_FETCH
1557
1521
if (result -> fetch_abs ) {
1558
1522
if (!pv_row_is_null && pv_row > 0 ) {
1559
1523
rc = SQLExtendedFetch (result -> stmt ,SQL_FETCH_ABSOLUTE ,(SQLLEN )pv_row ,& crow ,RowStatus );
1560
1524
} else {
1561
1525
rc = SQLExtendedFetch (result -> stmt ,SQL_FETCH_NEXT ,1 ,& crow ,RowStatus );
1562
1526
}
1563
- } else
1564
- #endif
1527
+ } else {
1565
1528
rc = SQLFetch (result -> stmt );
1529
+ }
1566
1530
1567
1531
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO ) {
1568
1532
if (rc == SQL_ERROR ) {
1569
- #ifdef HAVE_SQL_EXTENDED_FETCH
1570
1533
odbc_sql_error (result -> conn_ptr , result -> stmt , "SQLExtendedFetch" );
1571
- #else
1572
- odbc_sql_error (result -> conn_ptr , result -> stmt , "SQLFetch" );
1573
- #endif
1574
1534
}
1575
1535
RETURN_FALSE ;
1576
1536
}
1577
1537
1578
- #ifdef HAVE_SQL_EXTENDED_FETCH
1579
1538
if (!pv_row_is_null && pv_row > 0 && result -> fetch_abs )
1580
1539
result -> fetched = (SQLLEN )pv_row ;
1581
1540
else
1582
- #endif
1583
1541
result -> fetched ++ ;
1584
1542
1585
1543
for (i = 0 ; i < result -> numcols ; i ++ ) {
@@ -1659,10 +1617,8 @@ PHP_FUNCTION(odbc_fetch_row)
1659
1617
zval * pv_res ;
1660
1618
zend_long pv_row = 0 ;
1661
1619
bool pv_row_is_null = true;
1662
- #ifdef HAVE_SQL_EXTENDED_FETCH
1663
1620
SQLULEN crow ;
1664
1621
SQLUSMALLINT RowStatus [1 ];
1665
- #endif
1666
1622
1667
1623
if (zend_parse_parameters (ZEND_NUM_ARGS (), "O|l!" , & pv_res , odbc_result_ce , & pv_row , & pv_row_is_null ) == FAILURE ) {
1668
1624
RETURN_THROWS ();
@@ -1671,50 +1627,38 @@ PHP_FUNCTION(odbc_fetch_row)
1671
1627
result = Z_ODBC_RESULT_P (pv_res );
1672
1628
CHECK_ODBC_RESULT (result );
1673
1629
1674
- #ifndef HAVE_SQL_EXTENDED_FETCH
1675
- if (!pv_row_is_null ) {
1676
- php_error_docref (NULL , E_WARNING , "Extended fetch functionality is not available, argument #3 ($row) is ignored" );
1677
- }
1678
- #else
1679
1630
if (!pv_row_is_null && pv_row < 1 ) {
1680
1631
php_error_docref (NULL , E_WARNING , "Argument #3 ($row) must be greater than or equal to 1" );
1681
1632
RETURN_FALSE ;
1682
1633
}
1683
- #endif
1684
1634
1685
1635
if (result -> numcols == 0 ) {
1686
1636
php_error_docref (NULL , E_WARNING , "No tuples available at this result index" );
1687
1637
RETURN_FALSE ;
1688
1638
}
1689
1639
1690
- #ifdef HAVE_SQL_EXTENDED_FETCH
1691
1640
if (result -> fetch_abs ) {
1692
1641
if (!pv_row_is_null ) {
1693
1642
rc = SQLExtendedFetch (result -> stmt ,SQL_FETCH_ABSOLUTE ,(SQLLEN )pv_row ,& crow ,RowStatus );
1694
1643
} else {
1695
1644
rc = SQLExtendedFetch (result -> stmt ,SQL_FETCH_NEXT ,1 ,& crow ,RowStatus );
1696
1645
}
1697
- } else
1698
- #endif
1646
+ } else {
1699
1647
rc = SQLFetch (result -> stmt );
1648
+ }
1700
1649
1701
1650
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO ) {
1702
1651
if (rc == SQL_ERROR ) {
1703
- #ifdef HAVE_SQL_EXTENDED_FETCH
1704
1652
odbc_sql_error (result -> conn_ptr , result -> stmt , "SQLExtendedFetch" );
1705
- #else
1706
- odbc_sql_error (result -> conn_ptr , result -> stmt , "SQLFetch" );
1707
- #endif
1708
1653
}
1709
1654
RETURN_FALSE ;
1710
1655
}
1711
1656
1712
- #ifdef HAVE_SQL_EXTENDED_FETCH
1713
1657
if (!pv_row_is_null ) {
1714
1658
result -> fetched = (SQLLEN )pv_row ;
1715
- } else
1716
- #endif
1659
+ } else {
1717
1660
result -> fetched ++ ;
1661
+ }
1718
1662
1719
1663
RETURN_TRUE ;
1720
1664
}
@@ -1733,10 +1677,8 @@ PHP_FUNCTION(odbc_result)
1733
1677
RETCODE rc ;
1734
1678
SQLLEN fieldsize ;
1735
1679
zval * pv_res ;
1736
- #ifdef HAVE_SQL_EXTENDED_FETCH
1737
1680
SQLULEN crow ;
1738
1681
SQLUSMALLINT RowStatus [1 ];
1739
- #endif
1740
1682
1741
1683
ZEND_PARSE_PARAMETERS_START (2 , 2 )
1742
1684
Z_PARAM_OBJECT_OF_CLASS (pv_res , odbc_result_ce )
@@ -1787,20 +1729,14 @@ PHP_FUNCTION(odbc_result)
1787
1729
1788
1730
if (result -> fetched == 0 ) {
1789
1731
/* User forgot to call odbc_fetch_row(), or wants to reload the results, do it now */
1790
- #ifdef HAVE_SQL_EXTENDED_FETCH
1791
1732
if (result -> fetch_abs )
1792
1733
rc = SQLExtendedFetch (result -> stmt , SQL_FETCH_NEXT , 1 , & crow ,RowStatus );
1793
1734
else
1794
- #endif
1795
1735
rc = SQLFetch (result -> stmt );
1796
1736
1797
1737
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO ) {
1798
1738
if (rc == SQL_ERROR ) {
1799
- #ifdef HAVE_SQL_EXTENDED_FETCH
1800
- odbc_sql_error (result -> conn_ptr , result -> stmt , "SQLExtendedFetch" );
1801
- #else
1802
- odbc_sql_error (result -> conn_ptr , result -> stmt , "SQLFetch" );
1803
- #endif
1739
+ odbc_sql_error (result -> conn_ptr , result -> stmt , "SQLExtendedFetch" );
1804
1740
}
1805
1741
RETURN_FALSE ;
1806
1742
}
@@ -1948,10 +1884,8 @@ PHP_FUNCTION(odbc_result_all)
1948
1884
char * pv_format = NULL ;
1949
1885
size_t i , pv_format_len = 0 ;
1950
1886
SQLSMALLINT sql_c_type ;
1951
- #ifdef HAVE_SQL_EXTENDED_FETCH
1952
1887
SQLULEN crow ;
1953
1888
SQLUSMALLINT RowStatus [1 ];
1954
- #endif
1955
1889
1956
1890
if (zend_parse_parameters (ZEND_NUM_ARGS (), "O|s" , & pv_res , odbc_result_ce , & pv_format , & pv_format_len ) == FAILURE ) {
1957
1891
RETURN_THROWS ();
@@ -1964,11 +1898,9 @@ PHP_FUNCTION(odbc_result_all)
1964
1898
php_error_docref (NULL , E_WARNING , "No tuples available at this result index" );
1965
1899
RETURN_FALSE ;
1966
1900
}
1967
- #ifdef HAVE_SQL_EXTENDED_FETCH
1968
1901
if (result -> fetch_abs )
1969
1902
rc = SQLExtendedFetch (result -> stmt ,SQL_FETCH_NEXT ,1 ,& crow ,RowStatus );
1970
1903
else
1971
- #endif
1972
1904
rc = SQLFetch (result -> stmt );
1973
1905
1974
1906
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO ) {
@@ -2066,11 +1998,9 @@ PHP_FUNCTION(odbc_result_all)
2066
1998
}
2067
1999
php_printf ("</tr>\n" );
2068
2000
2069
- #ifdef HAVE_SQL_EXTENDED_FETCH
2070
2001
if (result -> fetch_abs )
2071
2002
rc = SQLExtendedFetch (result -> stmt ,SQL_FETCH_NEXT ,1 ,& crow ,RowStatus );
2072
2003
else
2073
- #endif
2074
2004
rc = SQLFetch (result -> stmt );
2075
2005
}
2076
2006
php_printf ("</table>\n" );
0 commit comments