2

I'm using wpdb to develop a plugin to add a custom form to wordpress. To update a row, I use an array and wpdb->update(). WP Class Reference says:

My SQL code should be something like UPDATE ROW .... WHERE a='a' AND b!='c'.

The problem is that != doesn't seem to be working, in fact from WP Class Reference

A named array of WHERE clauses (in column => value pairs).

I need to connect to an external database and fetch data from that database so I can't use any of the available plugins.

2

Here is exmaple code,You will change as per your requirement

$wpdb->query(
    "
    UPDATE $wpdb->posts 
    SET post_parent = 7
    WHERE ID = 15 
        AND post_status = 'static'
    "
);
  • 1
    The problem being wpdb::query doesn't return affected rows like wpdb::update does. – rebroken Dec 14 '15 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.