• Resolved allstar

    (@allstar)


    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?

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

    (@allstar)

    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!
    }
Viewing 1 replies (of 1 total)
  • The topic ‘wpdb – Any records returned?’ is closed to new replies.