過去 2 時間、エラーの解決策を見つけようとしています。特定のテーブルからエントリを取得しようとしていますが、常に
致命的なエラー: 18 行目の web_performance/models/MongoDbConnection.phpの非オブジェクトに対するメンバー関数 find() の呼び出し
何をすべきか提案はありますか?
これは私のデータベース接続クラスです
class MongoDbConnection {
private $_mongoDb=null;
private $_table;
public function __constructor($dbAddress='localhost') {
$this->_mongoDb=new Mongo($dbAddress);
}
public function setTable($argTableName){
$this->_table=$this->_mongoDb->$argTableName;
return $this;
}
//select method
public function find(){
$this->_table->find(); // <- Line 18
return $this;
}
//create insert method
/*public function insert($values){
$this->_table->insert($values);
return $this;
}*/
//update method
public function update($values){
$this->_table->update($values);
return $this;
}
//delete method
public function dbMongoDelete($values){
throw new Exception('Delete not yet defined in '.__CLASS__);
}
//end class
}
これは私の設定クラスです
module_load_include('php', 'web_performance', 'models/MongoDbConnection');
class BenchmarkingSettings {
private $_mongoDb;
static private $_instance;
public function __construct() {
$this->_mongoDb=new MongoDbConnection();
}
static public function getInstance() {
if (is_null(self::$_instance)) {
self::$_instance=new BenchmarkingSettings();
}
return self::$_instance;
}
public function populateFormWithValueSettings(){
$response=$this->_mongoDb->setTable("benchmarkingSettings")->find();
return $response;
}
}