• Resolved ShadyAce

    (@shadyace)


    Hi all,
    I’m fairly new to WordPress, and have only been developing plugins for about a week now.
    Overall it’s a very pleasant way of working and most things sort themselves out.
    But one thing I can’t seem to get done, is updating a row in my DB table

    I have tried lots of ways and searched a lot on the internet, but this is the best I can come up with, maybe i forgot something, or maybe some syntax that’s incorrect.

    global $wpdb;
            $foobarOptie = $_POST["foobar"];
            $deleteOptie = $_POST["DeleteData"];
            $table = "wp_cool_plugin_options";
            $data_array = array('idOptions' => 1, 'isFoobar' => $foobarOptie, 'DeleteData' => $deleteOptie);
            $where = "'idOptions' == 1";
    
            $wpdb->update( $table, $data_array, $where );

    Hopefully someone knows the solution, I’d be grateful 🙂

Viewing 1 replies (of 1 total)
  • Thread Starter ShadyAce

    (@shadyace)

    Oh I found the solution, apparently I wasn’t too far away.
    My where clause was faulty,
    I have now changed my code as follows:

    global $wpdb;
            $foobarOptie = $_POST["foobar"];
            $deleteOptie = $_POST["DeleteData"];
            $table = "wp_cool_plugin_options";
            $data_array = array('idOptions' => 1, 'isFoobar' => $foobarOptie, 'DeleteData' => $deleteOptie);
            $where = array('idOptions' => 1);
            $wpdb->update( $table, $data_array, $where );

    And now it works like a charm 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘Update Query’ is closed to new replies.