Re: #24206 [NEW]: PEAR::DB does not work properly with multiple databases

From: Date: Mon, 16 Jun 2003 16:49:56 +0000
Subject: Re: #24206 [NEW]: PEAR::DB does not work properly with multiple databases
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-17521@lists.php.net to get a copy of this message
I'm sorry to tell you that this works perfectly. I've actually done it several times. I guess your problem is that your query on Interbase is wrong and therefore returns a DB::Error Object. I guess that for Interbase you have to write your query : SELECT NAME FROM kod WHERE NAME LIKE '$code' instead of SELECT NAME FROM kod WHERE NAME='$code' which is not standard SQL, and doesn't work on many databases... Have you tried to print_r your $result2 object before printing the fetchRow() method invocation result ??? Hope this helps, Antoine. fretnoiz at yandex dot ru wrote:
From:             fretnoiz at yandex dot ru
Operating system: Windows 2000
PHP version:      4.3.2
PHP Bug Type:     PEAR related
Bug description: PEAR::DB does not work properly with multiple databases Description: ------------ If I create two different objects for database access, one of them does not work. For example, one DB object is connected to MySQL, second is connected to Interbase. Interbase does not return results properly. Reproduce code: --------------- define('DB_DSN1', 'mysql://max:max@localhost/autogarant'); define('DB_DSN2', 'ibase://SYSDBA:masterkey@localhost/C:\IB\autogarant'); $siteDB =& DB::connect(DB_DSN1); $cisDB =& DB::connect(DB_DSN2); $result1 =& $siteDB->query("SELECT NAME FROM kod"); if ($row = $result1->fetchRow(DB_FETCHMODE_ASSOC)) {
    $code = $row['NAME'];
    echo $code . "<br>\n";
    $result2 =& $cisDB->query("SELECT NAME FROM kod WHERE NAME='$code'");
    print_r($result2->fetchRow());
    echo "<br>\n";
} Expected result: ---------------- The tables in the DBs contain the same data so i expect to get equivalent records. 006.905 Array ( [0] => 006.905 ) Actual result: -------------- 006.905 Fatal error: Call to undefined function: fetchrow() in c:\Web\htdocs\test_pear.php on line 23
-- Antoine ANGENIEUX http://www.clever-age.com Clever Age - conseil en architecture technique GSM: +33 6 63 58 36 95 Tél: +33 1 49 01 28 63

« previous php.pear.dev (#17521) next »