Quantcast
Channel: Question and Answer » wpdb
Viewing all articles
Browse latest Browse all 44

Why is an empty result an error? ( $wpdb->get_row )

$
0
0

I have a query where I get the highest id from a table.

$user_id = $wpdb->get_row("SELECT * FROM $table WHERE id=(SELECT MAX(id) FROM $table)")

The table should always have rows, but if for some reason it returns empty, there is an error (printed with $wpdb->print_error()):

WordPress database error: []

I was wondering why an empty result means an error? And how would I prevent this error?


Viewing all articles
Browse latest Browse all 44

Trending Articles