Table Class: paginate() function and sorting

edited December 2011 in Feature Requests
Hello there,

I can't seem to find out how to set the ordering of the returned results when using the paginate($limit, $offset) function on a model like this

$this->my_model_name->paginate(10, 20)
I tried running a

$this->db->where()
with various parameters (even enforcing a single entry id, just to see) but that doesnt really affect the results in any way. I always end up getting results sorted by the default column i guess.
Also, is there a way to ask the results to be sent as objects instead of array?

Thanks a lot!

Comments

  • edited 7:07AM
    In your case, if you want to have an object and be able to sort, I'd recommend just using the find_all() method. The paginate function will always return an array and to do the sorting, you need to do:
    $this->db->order_by('col', 'asc');
  • edited 7:07AM
    me so dumb. all i had to do was use the $this->db functions in the model as opposed to doing it in the controller... i guess i was too tired : )
Sign In or Register to comment.