简体   繁体   English

如何在codeigniter活动记录中设置group_concat_max_len?

[英]How to set group_concat_max_len in codeigniter active record?

I have tried to set group_concat_max_len in codeigniter with $this->db->query('SET GLOBAL group_concat_max_len=15000') but it doesn't work. 我曾试图设置group_concat_max_len与笨$this->db->query('SET GLOBAL group_concat_max_len=15000')但它不工作。

I have tried like: 我尝试过:

$q = 'SET GLOBAL group_concat_max_len=15000';
$this->db->query($q);

$this->db->select("group_concat(id) ids");
$this->db->from("table_name");
$data = $this->db->get()->row_array();

but this does not give all data. 但这并不能提供所有数据。 any idea about this. 对此有任何想法。 Thanks!!! 谢谢!!!

I found solution by using SET SESSION instead of SET GLOBAL . 我通过使用SET SESSION而不是SET GLOBAL找到了解决方案。

Code is like : 代码如下:

$this->db->simple_query('SET SESSION group_concat_max_len=15000');

$this->db->select("group_concat(id) ids");
$this->db->from("table_name");
$data = $this->db->get()->row_array();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM