1

due to debugging and error hunting in a plugin, I have a quick question.

What does $wpdb->get_row() return in case there are no results? The documentation says:

(array|object|null|void) Database query result in format specified by $output or null on failure.

But when looking at the source code, it rather seems like it returns "null"...

A quick help would be appreciated, I always thought that it returns an empty array but I might be mistaken!

2 Answers 2

1

From the docs: Returns null if no result is found...

0

Yes, the docs are correct... but to check you could do something simple like

<?php
global $wpdb;
$result = $wpdb->get_row("SELECT * from $wpdb->posts where ID = '9999999'");
echo '<pre>'; var_dump( $result ); echo '</pre>';

Where the resulting output is

NULL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.