I write a Model class in PHP and this class has a $db property to store a database class object.
When I derive my class from Model class, if I want to access to $db object I must do this:
class post extends Model
{
function a()
{
return $this->db->find();
// .....
}
}
But I want to gain direct access to the database object in the post class, like this:
class post extends Model
{
function a()
{
return $this->find();
// .....
}
}
Is this possible?
Easiest way is to declare a find function in your class: