0
我有工作,但查詢不具備綁定值:準備默認查詢
$this->_db->query("SELECT * from posts WHERE post_title LIKE '%$this->search_keywords%' OR post_content LIKE '%$this->search_keywords%' LIMIT 100");
$this->rows_results_found = $this->_db->resultset();
$this->results_found_num = sizeof($this->rows_results_found);
我就重寫這一個,但沒有運氣:
$this->_db->query('SELECT * from posts WHERE post_title LIKE :search_keywords OR post_content LIKE :search_keywords LIMIT 100');
$this->_db->bind(':search_keywords', '%$this->search_keywords%');
$this->rows_results_found = $this->_db->resultset();
$this->results_found_num = sizeof($this->rows_results_found);
$ this-> results_found_num總是顯示爲空數組。
這是我在結果集()(這是從另一個外部類):
public function resultset() {
$this->execute();
return $this->stmt->fetchAll(PDO::FETCH_ASSOC);
}
我是缺少在這裏?
預先感謝您!
請RTFM如何使用準備好的語句:http://php.net/manual/ en/pdo.prepared-statements.php – deceze
嗯,只是爲了記錄,我寫了FK手冊。謝謝! :) –
...那麼你應該超過資格回答你自己的問題......?! :) \ * confused \ * – deceze