我正在尝试创建一个带有大小写的搜索查询,并且卡在错误“无效的参数编号”上。有人可以帮助我解决这个问题以及如何解决吗?
$query = 'SELECT *,
CASE WHEN o.title LIKE :keyword THEN 1
WHEN c.body LIKE :keyword THEN 2
ELSE 99 END AS priority
FROM orders AS o INNER JOIN
comment_relations AS cr ON o.id = cr.target_id INNER JOIN
comments AS c ON cr.comment_id = c.id
WHERE cr.type = 2
ORDER BY priority';
$stmt = $db->prepare($query);
$stmt->bindValue(':keyword', '%' . $search_keyword . '%', PDO::PARAM_STR);
表格如下
ORDER:
ID = 95
title = first order
COMMENT RELATIONS:
id = 1241
comment_id = 500
target_id = 95
type = 2
COMMENT:
id = 500
body = this is the first comment
答案 0 :(得分:2)