• ed4becky

    (@ed4becky)


    I have recently switched my plugin from using the mysql library to using the $wpdb API in WordPress.

    When using the mysql library, I would catch exceptions, and if it was for a duplicate entity, execute alternate logic and suppress the error.

    With $wpdb, the error is being returned in the response msg as an html block, followed by my json block.

    How do I suppress a specific error, i.e. if it is Duplicate entity error, I want to ignore it, else I want to have the error thrown as normal

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You could ensure duplicate entity errors cannot occur by verifying before attempting to insert. What else you could do depends on what $wpdb methods you are using. If it’s the generic wpdb::query(), you’d have to extend the class, overriding the query() method to handle errors the way you want.

Viewing 1 replies (of 1 total)
  • The topic ‘Ignore certain errors in $wpdb’ is closed to new replies.