$res->num_rows will not work on PostgreSQL. $db->num_rows() must be used
instead to execute the correct procedure depending on the database
backend.
But the call was not written properly and both were mixed up in commit
25741a618e which used $db->num_rows, and
then fixed in 72c443868c which used
$db->num_rows($result) where suited, except this location.