我有这个代码
$opslaglimit = 5;
$fag = "dansk";
$fagquery = "%".ucfirst($fag)."%";
$fagopslag = $db->prepare("
SELECT
*,
teacher_opslag.id as mainid,
teacher_opslag.created AS opslagcreated,
teacher_opslag.subject AS opslagsubject,
teacher_opslag.deleted AS maindeleted
FROM
teacher_opslag
WHERE
teacher_opslag.subject LIKE ?
ORDER BY
teacher_opslag.id DESC
LIMIT
$opslaglimit
");
$fagopslag->bind_param("s", $fagquery);
$fagopslag->execute();
$fagresult = $fagopslag->get_result();
$ensuranced = $fagresult->num_rows;
查询应选择表中存在dansk
的所有数据。我的一行可能看起来像Dansk_Engelsk_Svensk
。 num_rows返回0.
这是我第一次在LIKE
子句中使用WHERE
。我不知道为什么当我在db中有3个匹配行时它返回0。
请帮忙,谢谢