WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wpdb - Any records returned? (2 posts)

  1. allstar
    Member
    Posted 5 years ago #

    I'm reading and writing data from the database okay using wpdb, I want to do one set of instructions if I get something back from the query and another if I get nothing.

    How do I check if I got nothing back from a wpdb query?

  2. allstar
    Member
    Posted 5 years ago #

    Ended up using a switch for returned rows

    switch ( $wpdb->query('SELECT .....') ) {
    case "0" : // nothing in database
    case "1" : // one record
    case default : // many records or query breaks
    //there is an error as max should be one row!
    }

Topic Closed

This topic has been closed to new replies.

About this Topic