Skip to Content.
Sympa Menu

freetds - [freetds] FreeTds, Dblib, SQl server2000 and the strange case of drop queries

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Simone Magnaschi <simone.magnaschi AT rockol.it>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] FreeTds, Dblib, SQl server2000 and the strange case of drop queries
  • Date: Wed, 12 Nov 2014 12:40:09 +0100

Good morning to all.

I'm new to the mailing list, I subscribed since we're having issues on a new server deployment using FreeTDS. We were using FreeTDS before on a old server and everything was fine.


So we've got a new server with

* Debian Wheezy 32BIT
* PHP 5.5.18
* FreeTDS 0.91

This PHP app needs to talk to an old SQL server 2000 server. We used the old code from our previous server (PHP 5.2 and older FreeTDS - can't get the version unfortunately). We connect to SQL server 2000 through PDO using dblib driver.

We're experiencing weird behaviour with the fetch function. Basically if we issue a query during a fetch loop on the same pdo connection object, the main query gets reset and next fetch call will return false even if there are still records to be fetched.

|// PSEUDO CODE
// Here the main query
$q = $sql7->query("SELECT TOP 5 * FROM News ORDER BY Data Desc");
while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
// Looping through the results
echo "<h1>Main query</h1>";
print_r($row);

// Issue a query on the same pdo connection
$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);
}

// Here the main query $q->fetch(PDO::FETCH_ASSOC) will answer false on
the next iteration
// if we remove the subq, the main query loops just fine
echo "<hr>";
}
|

Same code on a Windows PHP with pdo_sqlserver driver works just fine.

It doesn't matter the type of fetch that we pass as argument of fetch function.

PHP doesn't throw any warning or error.

I really don't know what's going on here, and I don't know if it's an issue of PHP / FreeTDS / DBlib.

Any help would be great!


Thanks in advance
Simone Magnaschi





Archive powered by MHonArc 2.6.24.

Top of Page