there is neither a
PDO->connect_error nor a
PDOStatement->num_rows nor a
PDOStatement->fetch_object() property/method in PDO (these are all MySQLi properties/methods, PDO uses CamelCase).
additionally, there is no need to use a loop for a single result set. and the
catch() statement should be placed after all of the DB code.
btw. you don’t even need to test the number of results. if there is no (more) result available
PDOStatement->fetchObject() returns false, and since you can only have one result at most ...
The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
André Behrens, NY Times Software Developer