![]() |
Active Record error with order_by random - 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: Active Record error with order_by random (/showthread.php?tid=15839) |
Active Record error with order_by random - El Forum - 02-16-2009 [eluser]fatdog[/eluser] I'm getting this error. Quote:Unknown column ' RAND() LIMIT 1' in 'order clause' Code: $this->db->order_by("id","random"); Am I doing something wrong? I'm using version 1.7.0 Active Record error with order_by random - El Forum - 02-16-2009 [eluser]jdfwarrior[/eluser] What is the extra tick mark between order by and rand()? To me... your syntax looks correct. I just tried a similar query with something I have and it worked. I'm using 1.7.0 on that project too I believe. It may be 1.7.1 though, I don't remember. Code: $groups = $this->db->order_by("menugrouporder", "asc")->get("menugroups"); This was the code I used.. Active Record error with order_by random - El Forum - 02-16-2009 [eluser]fatdog[/eluser] [quote author="jdfwarrior" date="1234826985"]What is the extra tick mark between order by and rand()?[/quote] I don't know, that's the error I get. Either I'm doing something wrong, or there is a bug with "random", because if I try "asc" or "desc" instead of "random" the script works. Active Record error with order_by random - El Forum - 02-16-2009 [eluser]jdfwarrior[/eluser] I accidentally posted the code after I had changed it again. I used "random" and it still worked fine. As I said I dont remember which version I'm using. Maybe try upgrading to 1.7.1. Its just replacing contents of a few folders. Active Record error with order_by random - El Forum - 02-16-2009 [eluser]pistolPete[/eluser] [quote author="jdfwarrior" date="1234827788"]Maybe try upgrading to 1.7.1.[/quote] Definitely, just have a look at the changelog: Quote:Fixed a bug when doing 'random' on order_by() (#5706). Active Record error with order_by random - El Forum - 02-16-2009 [eluser]jdfwarrior[/eluser] Ha nice. |