11-27-2008, 10:56 AM
|
#4 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
I just thought of something else, that you would take great advantage of.
When you create your user class, in your construct, or in a setdb function, set a DB variable, something like this:
PHP Code:
class user { private $db;
public function __construct($db) {
if(is_object($db) {
$this->db = $db;
}
else throw new exception('Database must be an object!');
}
}
and:
PHP Code:
$db = new yourdbclass('params'); $user = new user($db);
I thought that this was pretty obvious, but I think that maybe someone doesn't know about it.
Anyways, what this does is that you can use the DB functions inside your user class, so whenever you query, you just do:
PHP Code:
$query = $this->db->queryfunction($sql);
Both looks good, and it's easy!
__________________
|
|
|
|