Re: [PEAR Newbie] PEAR problems

From: Date: Fri, 10 Oct 2003 12:39:08 +0000
Subject: Re: [PEAR Newbie] PEAR problems
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-30961@lists.php.net to get a copy of this message
Not user but I think the DB oject is not referenced because of function try the following to see if it works (not tested just a hunch)
require_once("DB.php");
    $dbname="c:\www\support\database\support.gdb";
    $dbuser="SYSDBA";
    $dbpass="masterkey";
    $dbhost="localhost";
    $db=DB::connect( "ibase://$dbuser:$dbpass@$dbhost/$dbname" );
$sql = 'SELECT NAME, DESCRIPTION FROM MENUITEM'; $demoResult = $db->query($sql); if (DB::isError($demoResult)) {
    die ($demoResult->getMessage());
} $count = 0; $demoResult->fetchInto($row); if ($row = $demoResult->fetchRow()) {
    $count ++;
    echo "Line $count";
    echo $row[0] . $row[1]. "\n";
}
    $db->disconnect();
pete David Russell wrote:
Hi all, I have been developing in PHP/Interbase for about 2 years, and have just started a new PHP aplication. I wanted to use PEAR's DB abstraction, but am running into (big) problems. I am sure I am doing something really stupid, but let's try anyway External .inc.php file containing the following: require_once("DB.php"); Function Connect_DB() {
    $dbname="c:\www\support\database\support.gdb";
    $dbuser="SYSDBA";
    $dbpass="masterkey";
    $dbhost="localhost";
    $db=DB::connect( "ibase://$dbuser:$dbpass@$dbhost/$dbname" );
    return $db;
} Function Disconnect_DB($db) {
    $db->disconnect();
} I include this file, and then have the following code: $db=Connect_DB(); $sql = 'SELECT NAME, DESCRIPTION FROM MENUITEM'; $demoResult = $db->query($sql); if (DB::isError($demoResult)) {
    die ($demoResult->getMessage());
} $count = 0; $demoResult->fetchInto($row); if ($row = $demoResult->fetchRow()) {
    $count ++;
    echo "Line $count";
    echo $row[0] . $row[1]. "\n";
} Disconnect_DB($db); The database Seelct statement should return 2 populated rows (and does in other app) The problem is that this section is either totally ignored, or it returns millions of lines with blank $row resurls (ie lines of "Line1\nLine2\n, etc) Where am I going wrong? Thanks in advance... David R


« previous php.db (#30961) next »