Handling database query errors

3 views
Skip to first unread message

Alexander Obuhovich

unread,
Dec 14, 2010, 9:23:31 AM12/14/10
to In-Portal Development
In-Portal has kDBConnection class, that can handle any type of database interactions. When database query being executed produces an error, then it's handled differently based on criteria listed below:

  • debug mode enabled AND DBG_SQL_FAILURE option set in debug.php file - will be PHP fatal error and script stops
  • debug mode enabled AND DBG_SQL_FAILURE option not set in debug.php file - will be PHP warning and script continues to execute
  • debug mode is disabled - will be PHP warning and script continues to execute
All works ok, until you need to check if last database query ended with error in last 2 cases from above mentioned.

Class kDBConnection has "getErrorCode", "getErrorMsg" and "hasError" methods, that do the trick, but if there was a query with error before checked query, then error isn't cleared an all methods will tell, that there is an error, but there are none.

I propose to reset "last remembered error information" before running new database query.


--
Best Regards,

http://www.in-portal.com
http://www.alex-time.com

Dmitry Andrejev

unread,
Dec 14, 2010, 11:14:17 AM12/14/10
to in-por...@googlegroups.com
Sure, I agree on this.

Please create a task with a patch and put in 5.1.2 for testing or Future (can go to 5.1.3)

DA.
--


Best regards,

Dmitry A.

Alexander Obuhovich

unread,
Dec 14, 2010, 11:21:00 AM12/14/10
to in-por...@googlegroups.com

Alexander Obuhovich

unread,
Dec 30, 2010, 8:01:42 AM12/30/10
to in-por...@googlegroups.com
Here is the patch. Ready for testing.
reset_db_error_before_each_query.patch
Reply all
Reply to author
Forward
0 new messages