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