Order by name not work with array. |
I am trying to be able to use two order by in my get_forums function
This is my out put I am try order the parents names so it would show like the codeigniter categories first but shows php categories first. $this->db->order_by('fid', 'asc'); // This is working $this->db->order_by('name', 'asc'); Code: Array Model PHP Code: <?php
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
You're ordering by "fid" first and "name" second. Unless there's a duplicate "fid" in the result set, the "name" ordering will never be used. What did you expect?
(12-07-2016, 03:20 AM)Narf Wrote: You're ordering by "fid" first and "name" second. Unless there's a duplicate "fid" in the result set, the "name" ordering will never be used. What did you expect? In my make parent list function which is called in get_forums I have another fid I am not sure if that is effecting it I have attached the Model file to the OP. Not sure if I done it all correct if any improvements can make let me know cheers.
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
i dont think is that possible to sort two column through a single query but you can do one thing first receive the data which you got from the database then again sort the array value using rsort().
(12-07-2016, 03:25 AM)wolfgang1983 Wrote:(12-07-2016, 03:20 AM)Narf Wrote: You're ordering by "fid" first and "name" second. Unless there's a duplicate "fid" in the result set, the "name" ordering will never be used. What did you expect? I don't know what you're talking about ... I don't need to look at your entire model, you've shown this: Code: $this->db->order_by('fid', 'asc'); You're ordering by fid first and name second. That's what I'm saying. (12-07-2016, 03:54 AM)kishorpant1991 Wrote: i dont think is that possible to sort two column through a single query but you can do one thing first receive the data which you got from the database then again sort the array value using rsort(). Yes you can, that's his entire problem. |
Welcome Guest, Not a member yet? Register Sign In |