[theforum] PEAR DB problem with DB_FETCHMODE_OBJECT
Flavio Hallais
fhallais2004 at yahoo.com
Mon Aug 2 22:24:39 CDT 2004
Hi all,
I have a box running:
Fedora Core 2
Apache 2.0.50
php-4.3.8 ( with pear )
postgresql-7.4.2
The FC2, Apache and PostgreSQL are running all right.
I'm trying to learn how to develop PHP applications
using the Pear DB Database abstration layer.
When I run this code:
<?php
require_once 'DB.php';
$db = DB::connect('pgsql://user:pass@localhost/auth');
if (DB::isError($db))
die($db->getMessage());
$result = $db->query('SELECT * FROM users');
while($row = $result-> fetchRow()){
echo $row[0];
}
?>
Everything works fine because the default for the
fetchRow mode is DB_FETCHMODE_ORDERED.
When I try run :
<?php
require_once 'DB.php';
$db = DB::connect('pgsql://user:pass@localhost/auth');
if (DB::isError($db))
die($db->getMessage());
$db->SetFetchMode(DB_FETCHMODE_OBJECT);
$result = $db->query('SELECT * FROM users');
while($row = $result-> fetchRow()){
echo $row->USER_ID;
}
?>
It does not work. I receive the message:
Notice: Undefined property: USER_ID in
/var/www/html/framework/testpear.php on line 12
USER_ID is a valid column in the table users !
Every piece of documentation says it should work.
What I am doing wrong ? ? ?
Can anyone help me ?
Thanks,
Flavio Hallais
__________________________________
Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now.
http://messenger.yahoo.com
More information about the theforum
mailing list