I have this trouble: in Model class me create a protected variable, but in child of Model class, he is not available.
class Model{
protected $db = null;
public function __construct(){
require_once 'app/classes/db.php';
$db = new DB();
}
}
This is their child:
class Model_Main extends Model{
public function get_data(){
$db->select('news');
}
}
Error:
Notice: Undefined variable: db in /var/www/localhost/htdocs/app/models/model_main.php on line 5
Fatal error: Call to a member function select() on null in /var/www/localhost/htdocs/app/models/model_main.php on line 5
$this->db- meagar♦