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