我已经创建了这个父类
class DBMysqli {
private $mysqli;
function __construct($Mysqli) {
$this->mysqli = $Mysqli;
}
public function GET($queryArr){
$query = "SELECT ";
...
$result = $this->mysqli->query($query); //Here I get a run time error!!
echo $this->mysqli->error;
return $result;
}
}
和一个儿童班
class FolderComment extends DBMysqli{
protected $data;
public function __construct() {
$this->mysqli = DB::Simulator(); //works, initiliaze $mysqli
$table = array(
'tables' => 'folder_comments',
'conditions' => '1'
);
$this->data = $this->GET($table);
}
}
我收到运行时错误,指出 $this->mysqli 为空。但我已将其设置在子类中。我想这是一个 OOP 轻描淡写的问题。