I would think the following piece of code should work, but it doesn\'t (Edited: Now works in PHP 5.5+):
if (!empty($r->getError()))
I usually create a global function called is_empty() just to get around this issue
function is_empty($var) { return empty($var); }
Then anywhere I would normally have used empty() I just use is_empty()