What should I return false, exception, etc
<p>I have a method which creates an object of the User class, But If the user is not found I need to return something, but I am not sure WHAT:</p>

<pre><code>function getUserById($id)
{
    $sth = $this-&gt;db-&gt;prepare("SELECT id, username, password, salt, email, created, last_active FROM users WHERE id = ?");
    $sth-&gt;execute(array($id));

    $sth-&gt;setFetchMode(PDO::FETCH_OBJ);

    if ($sth-&gt;rowCount() == 0) {
        //return what?
    }

    $row = $sth-&gt;fetch();
    $user = new User($row);

    return $user;
}
</code></pre>

<p>And the method should be used something like this:</p>

<pre><code>$user = $user_mapper-&gt;getUserById($id);
</code></pre>

<p>The question is how should I handle If the user is not found? Should I use a try catch block and then throw an exception in the rowCount == 0 if statement, or just return false and use a if statement when I set the $user variable to the object?</p>
