Sorting an Array with Objects |
[eluser]elaniobro[/eluser]
This is a sql result. I thought I already was doing such via my for loop. To recap, when I do the following: Code: <?php the results are displayed like so: id=>90 id=>80 id=>70 id=>4 id=>5 when I need it to be displayed like so: id=>4 id=>5 id=>90 id=>80 id=>70 It is just displaying the order of how they appear in the database.
[eluser]elaniobro[/eluser]
[quote author="noctrum" date="1268103643"] Code: $this->db->order_by('id ASC'); That would then go in the controller as such? Code: $data['query'] = $this->db->get('resume');
[eluser]danmontgomery[/eluser]
It needs to go before get() Code: $this->db->order_by('id ASC')->get('resume'); http://ellislab.com/codeigniter/user-gui...ecord.html
[eluser]elaniobro[/eluser]
[quote author="noctrum" date="1268104154"]It needs to go before get() Code: $this->db->order_by('id ASC')->get('resume'); http://ellislab.com/codeigniter/user-gui...ecord.html[/quote] Yes, I was just reading that page. Sheer genius when you see it spelled out, this makes total sense. Now I am about to go db sorting crazy! Thanks once again Noctrum.
[eluser]elaniobro[/eluser]
noctrum I have another question. In my controller I have the following query: Code: $data['built_date'] = $this->db->order_by('date DESC LIMIT 1')->get('thoughts'); I am trying to echo the date field of my database in the view as such: Code: <lastBuildDate><?php print_r( $built_date->result('WHERE date'));?> I have tried doing 'date', but all my iterations and variants produce the same result: Code: <lastBuildDate>Array How can I make it so that the following is shown? Code: <lastBuildDate>2010-03-15 18:51:04</lastBuildDate> ?? I am stuck, and have tried multiple things with fail. |
Welcome Guest, Not a member yet? Register Sign In |