$condition = '200,310'; //these are numbers of pages for news to be driven out of
while (list($key,$nesto) = each($pluginid))
{
$getnm = $DB->query("SELECT articleid, categoryid FROM " . TABLE_PREFIX . "p".$nesto."_newy
WHERE lang = '$userlang'
AND settings > 0
**AND instr(categoryid, $condition)**
ORDER BY settings ASC, datecreated DESC");
$rows = $DB->get_num_rows($getnm);
}
此instr
无效。任何想法如何使这个工作? categoryid
包含一个数字。
答案 0 :(得分:2)
如果你想检查categoryid是否是$ condition中提供的那个,你必须切换参数的位置:
AND instr('$condition', categoryid) > 0
答案 1 :(得分:2)
尝试使用IN
代替INSTR
。 IN
可以使用索引,并且可能比INSTR
更快。
$DB->query("SELECT articleid, categoryid FROM " . TABLE_PREFIX . "p".$nesto."_newy
WHERE lang = '$userlang'
AND settings > 0
AND categoryid IN ($condition)
ORDER BY settings ASC, datecreated DESC");