mysqli_result::num_rows

Please verify.
If you still use php 5.2 but want to switch to mysqli driver $query->num_rows will not be set before fetching the rows.
For mysqli : a SELECT (and SHOW and DESCRIBE) statement will always return a mysqli_result, in other cases it will return a boolean, so we could just check the return type.