class Controller function __construct Session init try this- db new Da

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class Controller {
function __construct () {
Session::init();
try {
$this->db = new Database();
} catch (PDOException $e) {
die('Database not be connection.');
}
}
public function LoadModel($name) {
$path = MODEL_PATH . strtolower($name) . '_model.php';
if (file_exists($path)) {
require MODEL_PATH . strtolower($name) . '_model.php';
$modelName = $name . 'Model';
return new $modelName($this->db);
}
}
public function factory($view, $data_array = array()) {
$fenom = Fenom::factory(VIEW_PATH, DATA_PATH.'/cache');
$fenom->display($view.'.phtml', $data_array);
}