Support » Fixing WordPress » Does $wpdb->update always return 0 (zero) ?

  • I’m running the following query:

    $result = $wpdb->update($table_name , array( values here), array( 'id' => $eventID) );

    The query is executed and the data is updated.

    But echoing $result, shows the value 0 (zero).

    I’ve also doubled checked the query found in mysql_queries.log file and ran this in Toad for MySQL. The query executed just fine.

    So why does $wpdb->update return 0 (zero)?
    Shouldn’t this be 1 if successfully executed?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ok, so it doesn’t ALWAYS return 0.

    Using $wpdb->update in another plugin I have created, returns 1 when successfully executed.

    It returns the number of rows updated. I think the reason it returns 0 in the case you have is because you haven’t actually changed the content of any of the rows.

    In other words, in testing, if you keep running the query, it will return 1 the first time and then a 0 every time after. 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Does $wpdb->update always return 0 (zero) ?’ is closed to new replies.