Correct way of implementation of: DAO Design Pattern php+pdo
<pre><code>class UserMapper {

    protected $db;

    public function __construct(PDO $db) {
        $this-&gt;db = $db;
    }

    public function save(User $user_object)
    {

    }


    public function getUserById($id)
    {
        //code
    }


}

class User {

    private $id;
    private $username;

    function __construct($user_row = null) 
    {
        if (!is_null($user_row)) {
            $this-&gt;id = $user_row-&gt;id;
            $this-&gt;username = $user_row-&gt;username;
        }
    }

    public function __set($name, $value)
    {
    }

    public function __get($name)
    {
        return $this-&gt;$name;
    }

}
</code></pre>

<p>Example:</p>

<pre><code>$user = new User();
$user-&gt;username = 'New Username';
$user_mapper = new UserMapper($db); //Pdo object = $db
$user_mapper-&gt;save($user);
</code></pre>

<p>Is this the correct way of implenting the pattern?</p>
