-1
我有這樣的代碼:依賴注入的構造 - 型暗示不工作
<?php
namespace Http\Models;
class DbModel {
private $dbh;
public function __construct(\Ilib\Database\Database $dbh) {
$this->dbh = $dbh;
}
public function select(){
$this->dbh->query("SELECT * from prednasky ORDER by mesic ASC"); }
}
}
我看到錯誤:
Catchable fatal error: Argument 1 passed to Http\Models\DbModel::__construct() must be an instance of Ilib\Database\Database, none given, where Ilib\Database\Database is the connection into the pdo db.
但我的問題是,我在哪裏可以創建一個新的實例?以及它如何看待這個實例?
好,作品非常感謝你 – user2579395