foo@bar:~$ printf 'SELECT * FROM users' | psql -U foo foo user_id | username | mail_host | alias | language | preferences ---------+----------------------+-----------+-------+----------+------------- 34 | testuser@terrist.org | localhost | | en_US | (1 row) foo@bar:~$ cat /tmp/test.php #!/usr/bin/php getMessage().' - '.$dbh->getUserinfo()); } $query = 'SELECT * FROM users'; $result = $dbh->query($query); // check if the query was executed properly if (PEAR::isError($result)) { echo ($result->getMessage().' - '.$result->getUserinfo()); exit(); } // lets just get row:0 and free the result $array = $result->fetchRow(MDB2_FETCHMODE_ASSOC); var_dump(array('row' => $array)); $result->free(); $dbh->disconnect(); foo@bar:~$ /tmp/test.php array(1) { ["row"]=> NULL } foo@bar:~$