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?
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?
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!
}This topic has been closed to new replies.