本文介绍了Codeigniter GROUP_CONCAT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有:
$this->db->select('GROUP_CONCAT(prod_poster, poster2, poster3, poster4, poster5, poster6, poster7)');
我对此有错误并显示sql查询:
And I have error for this and shows sql query:
SELECT GROUP_CONCAT(prod_poster, `poster2`, `poster3`, `poster4`, `poster5`, `poster6`, `poster7)`
是由于海报7附近的->>>> `而引起的问题.此符号必须在方括号内.whyc codeigniter这样做吗?以及如何解决?
it's problem because of ->>>> ` near poster7. this symbol must be inside bracket. whyc codeigniter do like this? and how to fix it?
推荐答案
尝试做:
$this->db->select('GROUP_CONCAT(prod_poster, poster2, poster3, poster4, poster5, poster6, poster7)', false);
如果将false作为 select()
的第二个参数传递,它将不会尝试通过添加反引号来保护您的查询(如示例中所示).
If you pass false as the second argument of select()
, it won't try to protect your query by adding in backticks (like it has in your example).
请参阅: https://codeigniter.com/userguide2/database/active_record.html#select
这篇关于Codeigniter GROUP_CONCAT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!