Let's say that I have this class that connects to the database and another class that tells me what type of foobars are in the database and various information about them.
What would the proper way to use these two like classes together?
class db {
function query() ...
}
class foobar extends db {
function getID(){
$this->query()...
}
}
$foo = new foobar;
or
class db {
function query() ...
}
class foobar {
var $object;
function foobar($obj){
$this->object = $obj;
}
function getID(){
$this->object->query()...
}
}
$db = new db;
$foo = new foobar($db);
Or am I off?
How would you do this three deep? i.e. db, foo, bar
TIA