{"id":805,"date":"2022-08-30T15:07:28","date_gmt":"2022-08-30T15:07:28","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/codeigniter-how-to-catch-db-errors-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:07:28","modified_gmt":"2022-08-30T15:07:28","slug":"codeigniter-how-to-catch-db-errors-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/codeigniter-how-to-catch-db-errors-collection-of-common-programming-errors\/","title":{"rendered":"CodeIgniter &#8211; how to catch DB errors?-Collection of common programming errors"},"content":{"rendered":"<p>Is there a way to make CI throw an exception when it encounters a DB error instead of displaying a message like:<\/p>\n<pre><code>A Database Error Occurred\nError Number: 1054\n\nUnknown column 'foo' in 'where clause'\nSELECT * FROM (`FooBar`) WHERE `foo` = '1'\n<\/code><\/pre>\n<p>NOTE: I only want this to happen in one controller. In the other controllers, I&#8217;m happy for it to display the DB error messages.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:46:27. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Is there a way to make CI throw an exception when it encounters a DB error instead of displaying a message like: A Database Error Occurred Error Number: 1054 Unknown column &#8216;foo&#8217; in &#8216;where clause&#8217; SELECT * FROM (`FooBar`) WHERE `foo` = &#8216;1&#8217; NOTE: I only want this to happen in one controller. In the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-805","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=805"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/805\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}