PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB » Bug #2552

query works fine first time only

Details

Submitted2004-10-18 03:39 UTC
Frommiguelmattos at via-rs dot net
Assigneddanielc
StatusBogus
PackageDB
PHP Version5.0.2
OSDebian
Roadmaps(Not assigned)

Comments

[2004-10-18 03:39 UTC] miguelmattos at via-rs dot net

Description:
------------
Testing a simple select (select * from table) against a mssql database server using the sybase driver.
One script using php sybase native functions, the other, using pear.
With the pear script, the query returns the expected data, the first time the script is executed. Any further attempt to execute the script will return nothing, no errors reported.
After restarting the web server (apache), it will work again (just for the first time).

The script using php sybase native functions works all the time.

Appreciate any advice.
Regards,
Miguel.

Reproduce code:
---------------
<?php
// The pear::db script

ini_set('include_path', '/usr/share/php');

require_once 'DB.php';

$dsn = array(
'phptype' => 'sybase',
'username' => 'user',
'password' => 'password',
'hostspec' => 'database',
'database' => 'database'
);

// freetds has an entry in freetds.conf with the same name
// of the database, that's why hostspec => database.

require_once("DB.php");
if (DB::isError($db = DB::connect($dsn)))
{
die("<br>" . $db->getMessage() . "<br>Native: " . $db->getDebugInfo());
}
$db->setFetchMode(DB_FETCHMODE_ASSOC);

$query = "SELECT * FROM MIDIAS ORDER BY MIDIA";
if (DB::isError($result = $db->query($query)))
{
echo "<br>" . $result->getMessage() . "<br>Native: " .
$result->getDebugInfo();
}

print_r($result);
while ($row = $result->fetchRow())
{
echo "<pre>";
print_r($row);
echo "</pre>";
}
$result->free();

$db->disconnect();
?>

<?php
// the script using the sybase native functions...

$c1 = sybase_pconnect("192.168.1.3" ,"user" ,"password","");

sybase_select_db("database",$c1);

$result = sybase_query("SELECT * FROM MIDIAS ",$c1);

$data_result = sybase_fetch_array($result);

print_r($data_result);

?>

Expected result:
----------------
Array with the table data.

Actual result:
--------------
Empty DB_Result Object.

[2004-10-18 04:58 UTC] miguelmattos at via-rs dot net

Ok, you are rigth.
It used to work on php4.
Using sybase (php) extension on linux to access mssql server.
The driver is the same for both: freetds.

Regards,
Miguel.

[2004-10-19 15:30 UTC] miguelmattos at via-rs dot net

Tried it now with ODBC.
Configured DSN using unixODBC through FreeTDS, isql working ok, php odbc native functions (as in last example working ok too).
Tried with PEAR, (took me a while to figure out the connection string)... first time works ok, next one, returns nothing. Restart web server, works ok again.