![]() |
Order BY not working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Order BY not working (/showthread.php?tid=35877) |
Order BY not working - El Forum - 11-14-2010 [eluser]Thiago Leao[/eluser] Hi friends, I'm trying to Sort a list, but not working. Code: <?php I know there must be something very simple, but I'm not getting. I'm new at CI, i'm sorry! thanks Order BY not working - El Forum - 11-14-2010 [eluser]Georgi Veznev[/eluser] [quote author="Thiago Leao" date="1289778449"]Hi friends, I'm trying to Sort a list, but not working. Code: <?php I know there must be something very simple, but I'm not getting. I'm new at CI, i'm sorry! thanks[/quote] Code: <?php Order BY not working - El Forum - 11-14-2010 [eluser]Thiago Leao[/eluser] so simple! =/ i'm sorry. thanks friend Order BY not working - El Forum - 02-19-2011 [eluser]Larry Wakeman[/eluser] I am having another problem with order by. The documentation states: Quote:Or multiple function calls can be made if you need multiple fields. This does not seem to be the case. I did a print_r on the query object and only the last call is there, the others are overwritten. I am using CI Version 1.7.2 at the moment. Thought about upgrading to 1.7.3 but when I looked, there were no translations for CI and localization is high on list of requirements for this project. Order BY not working - El Forum - 02-19-2011 [eluser]Georgi Veznev[/eluser] @larry Wakeman Please, post the function that isn't working? Order BY not working - El Forum - 02-19-2011 [eluser]InsiteFX[/eluser] orderby has been replaced with order_by ! Also do not use double qoutes, use single qoutes. InsiteFX Order BY not working - El Forum - 02-20-2011 [eluser]Larry Wakeman[/eluser] The code that is causing the issue is in a CRUD model, extended by table and view specific models. Code: function getAll($a_where = '', $a_order = null) The call is: Code: $this->a_items[$a_menu['id']] = $this->o_CI->menu_items->getAll(array('menuid' => $a_menu['id']), array('level'=> 'asc', 'parentid' => 'asc', 'order' => 'asc'); When I was debugging the code, I noticed that the sorting was by the last element in the ordering array. I dumped the $o_query object just before the get and verified that the last element was the only one that was in the object. I created a workaround as follows: Code: function getAll($a_where = '', $a_order = null) I may be naive but I was programming Fortran II on an IBM 1130 before most of the members of this forum were twinkles in their father's eyes and for many before their father was a twinkle... :-) and I have some silly notions that documentation should describe the real world, applications don't break computers, removing applications don't break computers. Order BY not working - El Forum - 02-20-2011 [eluser]Georgi Veznev[/eluser] Here is the code that is causing the problems. I think that this should work: Code: function getAll($a_where = '', $a_order = null) { Order BY not working - El Forum - 02-20-2011 [eluser]Larry Wakeman[/eluser] No joy! The order by clauses are being overwritten by the order_by call. The last one id the only one being sorted by. |