Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    100
    Plugin Contributions
    0

    Default how to catch the $db->Execute($sql) exception?

    I put a try and catch block around $db->Execute($sql), but when there is database exceptions (such as 1062 Duplicate primary key error), the error will simply be printed out on the page (to be exact, on a totally white page: so all other parts of the code is not executed).

    Does anyone have any idea of it? What I want to do is to be able to catch all the exceptions in $db->Execute($sql) call.

    Thanks!

  2. #2
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,896
    Blog Entries
    2
    Plugin Contributions
    2

    Default Re: how to catch the $db->Execute($sql) exception?

    The reason the try/catch fails is that all mysql function call errors are suppressed using the @prepend.

    You might want to look at the set_error method in the query factory which processes any errors.

 

 

Similar Threads

  1. v138a DB write randomly fails: how to catch it?
    By Prorad in forum General Questions
    Replies: 2
    Last Post: 15 May 2013, 11:47 PM
  2. do i have to execute sql to active quantity discount module?
    By wind9916 in forum Contribution-Writing Guidelines
    Replies: 2
    Last Post: 2 Aug 2010, 06:22 AM
  3. How to clone a database execute() result?
    By yellow1912 in forum Contribution-Writing Guidelines
    Replies: 1
    Last Post: 16 Dec 2007, 01:16 AM
  4. How do I run the stock_attribute.sql via Install SQL Patches in admin
    By vivaraquel in forum All Other Contributions/Addons
    Replies: 4
    Last Post: 9 Apr 2007, 01:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR