User class - 'load' data

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2012-04-14T11:19:42Z Indexed on 2012/04/14 11:28 UTC
Read the original article Hit count: 154

Filed under:
<?php

class User {

    private $id;
    private $username;

    public function __construct($id = null) {
        $this->id = $id;

        if (!is_null($this->id)) {
            $this->load();
        }
    }

    public function load() {


    }

}

?>

In the 'load' method I am going to load all the information from the current user (id) But I wonder how is the best way to load all info. I could grab all data and then just assign all private variables, but I assume there must be another "cheaper" way to get all the data so I can use as such

$this->variable;

And not have to ASSIGN every single data row, I select in the load method. How?

© Stack Overflow or respective owner

Related posts about php