Only the last value from the list of values retrieved from MySQL is stored in the variable in codeigniter

I’m trying to fetch a list of values from MySQL table using query1 and then use them in query2 to fetch values. Query1 gives 4 values however Query2 gives output matching the last value of Query1.

Following is my controller code

public function example_ctl(){
  $data['result'] = $this->some_model->example();
}

Following is my model code

public function example() {

        $query = "select m.queue_id from agent_queue_mapping_table as m, user_table as u where u.id=m.user_id and m.company_id = ".$this->session->userdata('user_comp_id')." and u.id = ".$this->session->userdata('user_id');

        $res = $this->db->query($query); 

        foreach ($res->result_array() as $value) {
            $queue_ids = implode(',', $value);
        }

        $query_ticket = "select * from tickets_table where company_id = ".$this->session->userdata('user_comp_id')." and ticket_status = 'New' and queue_id IN (".$queue_ids.") ORDER BY id DESC LIMIT 3";
        $res_ticket = $this->db->query($query_ticket);
        return $res_ticket->result_array();

 }

I’m not able to understand where I’m going wrong. Please help.


Download only.the.last.value.from.the.list.of.values.retrieved.from.mysql.is.stored.in.the.variable.in.codeigniter.zip
Direct Link


Download


Download only.the.last.value.from.the.list.of.values.retrieved.from.mysql.is.stored.in.the.variable.in.codeigniter.zip
Mediafire


Download


Download only.the.last.value.from.the.list.of.values.retrieved.from.mysql.is.stored.in.the.variable.in.codeigniter.zip
GigaPeta


Download

Both comments and pings are currently closed.

Comments are closed.