Why does this wordpress code throw an empty WPDB error?

I’m writing a feed reader plugin for wordpress. I’m seeing a DB error that I can’t figure out.
First I create a table called user_entries.
Then I put a sample entry into that table.
When I try to delete an entry, I get a very strange error in my debug log. There are no foreign keys yet, no indices on the db, etc.

[02-May-2012 11:21:52] WordPress database error for query
DELETE
FROM wp_wprss_user_entries
WHERE owner_uid = 2
AND feed_id = 2; made by do_action, call_user_func_array, wprss_unsubscribe_feed, WprssFeeds->remove

Read More

So what is the error? It’s just blank in there. This doesn’t look like complicated SQL and it works fine in the phpmysql query window. I’m not sure what to do for a next step now, and I’d like folks to be able to unsubscribe from a feed!

Related posts

Leave a Reply

2 comments

  1. Figured it out! $wpdb->print_error() prints that error string even if there isn’t an error. SO you have to check explicitly to see if the query returned false – not 0.

        if(false === $wpdb->query($sql)){
          $resp->uf_error = $wpdb->print_error();
        }
    
  2. Try spliting your Query so its only trying to delete from 1 WHERE clause..

    ie:

    DELETE FROM wp_wprss_user_entries WHERE owner_uid=2;
    run query
    DELETE FROM wp_wprss_user_entries WHERE feed_id=2;
    run query
    

    M