score:2

Accepted answer

maybe this happens because you're returning set of objects instead of arrays. since array_column() expects first parameter to be array, try to change $query->result() to $query->result_array() on each $data :

public function index()

{

    $query = $this->db->query("select sum(numberofclick) as count from demo_click 

        group by year(created_at) order by created_at"); 

    $data['click'] = json_encode(array_column($query->result_array(), 'count'),json_numeric_check);



    $query = $this->db->query("select sum(numberofview) as count from demo_viewer 

        group by year(created_at) order by created_at"); 

    $data['viewer'] = json_encode(array_column($query->result_array(), 'count'),json_numeric_check);



    $this->load->view('my_chart', $data);

}

Related Query

More Query from same tag