$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
只包含一个数字。
发布于 2011-10-24 23:00:55
如果你想检查categoryid是否是$condition中提供的任何一个,你必须改变参数的位置:
AND instr('$condition', categoryid) > 0
发布于 2011-10-24 23:01:34
尝试使用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");
https://stackoverflow.com/questions/7877585
复制相似问题