Stateful User tracking
Create static functions findById and findByUsername and clean-up User constructor or modify it to accept $id and $udata; you can also make it private, if you don't need it outside.

class User {
    // ...

    public static function findById (id) {
        // TODO
    }      

    public static function findByName (name) {
        // TODO
    }
}


$user = User::findById(51)
$user2 = User::findByName("JohnDoe")