WordPress.org

Ready to get started?Download WordPress

Forums

Does $wpdb->update always return 0 (zero) ? (3 posts)

  1. spstieng
    Member
    Posted 3 years ago #

    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?

  2. spstieng
    Member
    Posted 3 years ago #

    Ok, so it doesn't ALWAYS return 0.

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

  3. tychay
    Member
    Posted 3 years ago #

    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. :-)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags