PEAR is archived and read-only

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

Home » Database » DB » Bug #2111

Faulty Message from freeResults() in sybase.php

Details

Submitted2004-08-11 13:25 UTC
Fromphopfgartner at tin dot it
Assigneddanielc
StatusBogus
PackageDB
PHP Version4.3.8
OSDebian testing
Roadmaps(Not assigned)

Comments

[2004-08-11 13:25 UTC] phopfgartner at tin dot it

Description:
------------
When freeing a DB::result, somtimes a notice is generated.

Reproduce code:
---------------
<?php
require_once 'DB.php';

error_reporting(E_ALL);

$host = '';
$dbname = '';
$login = '';
$passwd = '';

$conn_str = sprintf("sybase://%s:%s@%s/%s", $login, $passwd, $host, $dbname);

$db = DB::connect($conn_str);

// Create temp table and fill it
$db->query('CREATE TABLE #test (id INT, name CHAR(10));');
$db->query("INSERT #test (id, name) VALUES (1, 'one')");

$query = 'SELECT id FROM #test WHERE id=1';

$result =& $db->query($query);
$qrow = $result->fetchRow();
$result->free();
?>

generates this message:
Notice: Undefined property: num_rows in /usr/share/pear/DB/sybase.php on line 375

This ugly patch quit the message:

--- sybase.php.old 2004-08-11 15:11:26.000000000 +0200
+++ sybase.php 2004-08-11 15:12:52.000000000 +0200
@@ -371,7 +371,9 @@
*/
function freeResult($result)
{
- unset($this->num_rows[(int)$result]);
+ if (isset($this->num_rows[(int)$result])){
+ unset($this->num_rows[(int)$result]);
+ }
return @sybase_free_result($result);
}

Expected result:
----------------
Notice: Undefined property: num_rows in /usr/share/pear/DB/sybase.php on line 375

[2004-08-30 16:02 UTC] phopfgartner at tin dot it

This code works on PHP on Windows. I changed my FreeTDS installation fro 0.61 to 0.62.4 and the code turned out to work flawlessly also on Linux. Summing up: This seems to be caused by bugs in FreeTDS 0.61 (with the FreeTDS upgrade a lot of problems with the Python Sybase driver and other software went away, too)