I am trying to write a CSV in Codeignter for a result set fetched from db.
I am already using the solution mentioned here. Reports in Codeigniter
But the issue is that it writes the whole table. Now I want to fetch and write specific records. So here is my model code.
    $where = "hangtag_spoc_number = 2202";
    $result = $this->db->select('*')
            ->from('hangtag_request')
            ->where($where)
            ->get()
            ->result_array();
    return $result;
It gives me this error.
You must submit a valid result object
If I change the model code to this
    return $query = $this->db->get('hangtag_request');
It works perfectly. Is there any way I can make my model code to return the results in the form of DB object? Coz it seems thats the form we need.
Thanks.