Home » Database » DB » Bug #9096
mssql_fetch_array() returns null in fetchInto()
Details
| Submitted | 2006-10-19 18:18 UTC |
|---|---|
| From | ausserirdisch at sven-space dot de |
| Assigned | aharvey |
| Status | Closed |
| Package | DB |
| PHP Version | 5.1.6 |
| OS | Debian Etch |
| Roadmaps | (Not assigned) |
Comments
[2006-10-19 18:18 UTC] ausserirdisch at sven-space dot de
Description:
------------
Enviroments:
- Debian Etch with Apache2 and PHP 5.1.6.
- Windows XP Pro SP2 with MS SQL Server 2000
I'm connecting from the Webapplication (Debian server) via PEAR::DataObject to the MS SQL server to import some data. It works fine with FreTDS. But there is one Problem occuring on the Debian system:
When I fetch the data then in DataObject::fetch() there will
be called at one time the DB_mssql::fetchInto() method. In this method the php-function mssql_fetch_array() is called. On a Windows system with PHP5 on Apache2 there is no problem. But on the Debian system this function returns null, because the function did not expect two parameters.
The next point I tried was to change the fetchmode of the fetchInto() method. Becaus in the class DB_mssql is an if-statement which checks the fetchmode and then calls either mssql_fetch_array with two parameter or mssql_fetch_row with one parameter (which works on the Debian system). But I found no clean way to set this fetchmode from my DataObject subclases. So I hacked the DB_mssql function fetchInto() that way, that it checks my superglobal variable if the server is a windows system or not an then calls the funtion mssql_fetch_rray with one or two parameters.
I searched around three days to solve this problem. There are some curious circumstances:
It seems that in the Debian PHP packages is no mssql-extension. Neither in the Etch package nor in the dotdeb-packages. Also not in the PHP4 Sarge package. So it seems that PEAR::DB loads the sybase_ct extension. And I guess, that then the function mssql_fetch_array() only can handle one parameter: the result.
Test script:
---------------
File: DB/mssql.php
Line: 311
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
{
if ($rownum !== null) {
if (!@mssql_data_seek($result, $rownum)) {
return null;
}
}
if ($fetchmode & DB_FETCHMODE_ASSOC) {
// returns always null and warning:
// unexpected parameter MSSQL_ASSOC
$arr = @mssql_fetch_array($result, MSSQL_ASSOC);
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
$arr = array_change_key_case($arr, CASE_LOWER);
}
} else {
$arr = @mssql_fetch_row($result);
}
if (!$arr) {
return null;
}
// ...
}