I have a little problem. I have a class named BaseModel. There is a pdo connection. Now i have a other class named TestModel and i extended the BaseModel class. But when i make a var_dump() on the pdo variable it returns null. I know the problem its because the constructer, but how do i make it? i need that constructer in the TestModel. But whitout constcuter the variable returns null. I Already tried whit parent::__construct()
but than the page loads infinite.
Here are my classes
BaseModel
<?php
namespace App\System\MVC\Models;
class BaseModel
{
protected $config;
protected $connection;
public function __construct($config, $connection)
{
$this->config = $config;
$this->connection = $connection;
}
public function __destruct()
{
$this->config = null;
$this->connection = null;
}
}
?>
TestModel
<?php
namespace App\System\MVC\Models;
use App\System\MVC\Models\BaseModel;
class TestModel extends BaseModel
{
protected $config;
protected $connection;
public function __construct()
{
var_dump($this->connection);
}
public function __destruct()
{
$this->config = null;
$this->connection = null;
}
}
?>
Please help me. Thanks
Sorry for bad english.