• I want to update the views only when certain things are shown… so i’ve a code for that.. but now to update it.. would this work???

    $wpdb->update( $table, array( 'views' => 'views'+1 ), array( 'id' => $new_result->id ) ); ?>

    or how do i increment it with the wpdb syntax?

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Jonas, you may want to consider retrieving the value of ‘views’ using a select:
    e.g
    $view = $wpdb->get_var( $wpdb->prepare( "SELECT view FROM $table WHERE id='$new_result->id';" ) );
    then incrementing it
    $views = $view+1;
    then running your update above with the new value

Viewing 1 replies (of 1 total)
  • The topic ‘sql update in wpdb: increment a column’ is closed to new replies.