So, we have a new server with
- Debian Wheezy 32BIT
- PHP 5.5.18
- FreeTDS 0.91
This PHP application needs to talk to the old SQL Server 2000 server. We used the old code from our previous server (PHP 5.2 and older FreeTDS - cannot get the version). We connect to SQL Server 2000 via PDO using the dblib driver.
We experience strange behavior with the fetch function. Basically, if we issue a request during a fetch cycle on the same pdo connection object, the main request gets reset, and the next call to fetch returns false, even if there are more records to be extracted.
$q = $sql7->query("SELECT TOP 5 * FROM News ORDER BY Data Desc");
while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
echo "<h1>Main query</h1>";
print_r($row);
$subq = $sql7->query("SELECT TOP 1 * FROM News WHERE IDNews = " . $row['IDNews'] . " ");
while ($subResult = $subq->fetch(PDO::FETCH_ASSOC)) {
echo "<h1>Inner query</h1>";
print_r($subResult);
}
echo "<hr>";
}
The same code on Windows PHP with the pdo_sqlserver driver works fine.
, fetch.
PHP .
, .