Welcome Guest, Not a member yet? Register   Sign In
Does this ever work?
#1

[eluser]cassowary[/eluser]
The User Guide is very sparse when it comes to explaining the use of this function. What it doesn't show is a full query construction with it: from loading the database library, creation of the main query, addition of ordering function then (crucially) execution and traversing of the results.
I have tried to get order_by to work by following the user guide so far as it goes and it simply will not work. I've had to resort to concatenating the ordering clause myself.
Does anyone have any examples in which this has worked? I've tried a Google search but (rather ironically) have only encountered pages in which some person or other is cursing CI's ActiveRecord. I like CodeIgniter but think the User Guide could be a lot better in this regard - it is just too vague.
#2

[eluser]n0xie[/eluser]
Show us what you tried.
#3

[eluser]jtkendall[/eluser]
In the future please use a more descriptive title.

Is this what you're looking for?

Code:
$this->load->database();
$this->db->where('field', 'value');
$this->db->order_by('field', 'asc');
$result = $this->db->get('table')->result();
foreach($result as $row):
//whatever you want to do here
endforeach;




Theme © iAndrew 2016 - Forum software by © MyBB