【发布时间】:2020-02-08 05:40:41
【问题描述】:
我的查询有什么问题?
$query = "SELECT * FROM wp_posts WHERE post_status = 'publish' AND post_title LIKE '%".$searchKey."%'";
在这种情况下,查询工作正常:
SELECT * FROM wp_posts WHERE post_status = 'publish' AND post_title LIKE '%hello%'
当我尝试向查询中添加变量时,它不起作用
public function search_result($searchKey)
{
$query = "SELECT * FROM wp_posts WHERE post_status = 'publish' AND post_title LIKE '%".$searchKey."%'";
return $this->wpdb->get_results($query);
}
【问题讨论】:
-
您能详细说明“不起作用”是什么意思吗?