我在PHP索姆問題,我把這個代碼在我的index.php:(PHP/OOP)方法不會在兩個方向上工作
$test = $wke ->sql
->insert("test")
->values(array("foo" => "bar"))
->go();
此代碼工作得很好,但是當我使用這個代碼一種方法(debug.class.php)是這樣的:
$test = sql::insert("test")
->values(array("foo" => "bar"))
->go();
它不工作:
Fatal error: Call to undefined method template::values() [...]
我的 「插入」(和 「值」)的方法是在我的SQL類,不是我的模板課。我知道我的第二個例子在我的模板類中調用,但在最後,我調用了sql :: insert,而不是self :: insert或template :: insert。這就是我迷失的原因。
對不起,我的英文!先謝謝你。
PS:這是我的SQL :: insert方法
static $queryBuffer;
public function insert($in) {
self::$queryBuffer->type = "insert";
self::$queryBuffer->data->insert = $in;
return $this;
}
由於在你的SQL類中'insert'不是'static',我不認爲你可以使用'sql :: insert'。 – Passerby