Search code examples
phpcodeignitergroup-concat

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.

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!!!


Solution

  • I found solution by using SET SESSION instead of 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();