$this->db->select_max() |
[eluser]borgir[/eluser]
Hey there! Anyone knows how can I get the result of the following query: Code: $this->db->select_max('field'); ? I've tried: $query->result(); foreach ... But without success. Thks!
[eluser]bretticus[/eluser]
a max() on one field should never return more than one result. See "row()" under Generating Query Results.
[eluser]borgir[/eluser]
Found it: Code: foreach ($query->result() as $row) { Source: http://ellislab.com/codeigniter/user-gui...sults.html Cheers!
[eluser]borgir[/eluser]
[quote author="bretticus" date="1254345809"]a max() on one field should never return more than one result. See "row()" under Generating Query Results.[/quote] Thks bretticus! Actually thats how I've solved it. Cheers!
[eluser]bretticus[/eluser]
[quote author="borgir" date="1254345964"] Thks bretticus! Actually thats how I've solved it. Cheers![/quote] You are certainly welcome. Just a little note. You will not require a for loop for this. You can call $query->row() directly.
[eluser]n0xie[/eluser]
Or use chaining (if you use PHP5) Code: $this->db->select_max('field'); |
Welcome Guest, Not a member yet? Register Sign In |