I'm running a query inside my model which returns results based on other results from a previous query, the query works perfectly fine, however it only returns a single row instead of all rows like it should.

I've tried returning the `$rows[]` in an array but that doesn't work, the query doesn't generate any results based on the first query, as I said though, there has to be a way to create these arrays in the controller given I return `result_array();`.

> 
> model
> 
> 
> 

```
public function category_id_results($category) {

  return $this->db->
  select('*')->
  from('categories')->
  where('parent_id', $category)->
  get()->result_array();
}
public function category_results($category, $id) {

  print_r($id);
  $where = "category_id='$id' OR category_id='$category'";
  $this->db->where($where);
  $query = $this->db->get('records');

  $rows = array();
  foreach ($query->result_array() as $row) {

    $rows[] = array(
     //Rows
    );
  }
  return $rows;
}

```

> 
> controller
> 
> 
> 

```
  $this->load->model('Main');
  $category = $_GET["category"];

  $data['id_cat'] = $this->Main->category_id_results($category);
  echo "<pre>";
  print_r($data['id_cat']);
  echo "</pre>";
  $id = $data['id_cat']['id'];

  $data['category_results'] = $this->Main->category_results($category, $id);

```

When I run a `print_r($data['id_cat']);` I get the expected output(all rows), it does however tell me that the `id` index is undefined. Also when I do this my query doesn't work properly either.