This is a pretty newbie question but my google keyword skills did not seem to help.
I am very new to OOP - I used to do everything procedural until not a long time ago.
I have a database class that I use to connect and talk to my database.
I have another class (user class) which is supposed to add a user to the database.
I need to somehow make my user class use the db class, and trying to include it with the __construct thing did not work...
This is what I tried
Code: Select all
class User{
public $error;
public $db;
public function __construct(){
require_once "db.class.php";
$this->db = new DB;
}
public function create($username, $password){
//...
}
}
Please help.
Thanks!
Yuval
EDIT: If I use 'extends' for the DB class (though it's not really extending it) will I be prevented from extending the User class?