管道charecters表达式引擎查询中的数据作为参数

时间:2014-05-13 06:48:36

标签: mysql sql expressionengine

$query =  $this->EE->db->query("SELECT * FROM exp_categories WHERE parent_id=$parent_id order by cat_id ASC");

and $parent id = 4|7|5|6 (for category parent id passed from template by user)

现在查询应返回父ID的结果。

它仅显示最后一个父ID的结果。

1 个答案:

答案 0 :(得分:0)

不完全清楚你在问什么。我想你希望你的查询是:

SELECT * 
FROM exp_categories 
WHERE parent_id 
IN (4, 5, 6, 7) 
ORDER BY cat_id ASC;

如果需要,你需要从管道列表中取出$ parent_id(4 | 7 | 5 | 6)并将其转换为以逗号分隔的列表(4,5,6,7)。

相关问题