F1Fan Posted October 15, 2008 Share Posted October 15, 2008 Hello. I've been using PEAR for a while, but I'm just now getting in deeper. I have a (hopefully) simple question; How can I simply check so see if a data manipulation query successfully executed? I'm looking for just a TRUE/FALSE determination. I'm sorry if this is a duplicate post, but I couldn't find anything on this. I'm not looking to find an error, or display the error, I just want to know if there was one. Nothing more. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/128596-pear-db-error-handling/ Share on other sites More sharing options...
Chicken Little Posted October 15, 2008 Share Posted October 15, 2008 Do you mean something like if (!mysql_query) { die(' Error: ' . mysql_error("False")); } echo "True"; or something like public function DbQuery($queryString) { $result = $this->db->query($queryString); if (DB::isError($result)) trigger_error($result->getMessage(), E_USER_ERROR); return $result; } Quote Link to comment https://forums.phpfreaks.com/topic/128596-pear-db-error-handling/#findComment-666460 Share on other sites More sharing options...
F1Fan Posted October 15, 2008 Author Share Posted October 15, 2008 Yes. My company uses PostgreSQL, but it would be almost exactly the same as the "mysql_query()" function that returns TRUE on success, and FALSE on error. I found some documentation that led me to something close to your second suggestion: <?php // $db is my PEAR DB Object $result = $db->query($query); return DB::isError($db); ?> As you can see, I'm checking the object itself for the error, which is how the PEAR manual shows it: http://pear.php.net/manual/en/package.database.db.db-error.php Should it be the $result variable instead? Quote Link to comment https://forums.phpfreaks.com/topic/128596-pear-db-error-handling/#findComment-666473 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.