Re: error returning with PEAR::DB
| From: | Nelson E. Castillo | Date: | Tue, 30 Mar 2004 20:15:15 +0000 |
| Subject: | Re: error returning with PEAR::DB | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11541@lists.php.net to get a copy of this message | ||
$result =& $db->query('INSERT bla bla...');
> // check if an error occurred
> if (is_a($result, 'DB_error')) {
echo 'Standard Message: ' . $result->getMessage() . "\n".
'Standard Code: ' . $result->getCode() . "\n".
'DBMS/User Message: ' . $result->getUserInfo() . "\n".
'DBMS/Debug Message: ' . $result->getDebugInfo();
> }
> }
Hello.
I am new to PEAR myself but I guess this
information could help, as it helped me yesterday.
You could (but probably should not) parse the DBMS
user message to tell what happened. I would prefer
to do the query to find out whether the user
exists. It will be rather fast if you set an index
for the 'username' field -if it's not not your
primary key-.
Saludos cordiales,
Nelson.-
--
http://geocities.com/arhuaco
The first principle is that you must not fool yourself
and you are the easiest person to fool.
-- Richard Feynman.