return all row except last in |
[eluser]matches[/eluser]
Hello all, What is the best way to return all rows except the most recent entry. Does CI's database class of a good way to do this. Thanks
[eluser]osci[/eluser]
I don't think such a function would be needed in the db class. You can always get the insert id and run a query excluding that id.
[eluser]bproctor[/eluser]
There's probably a more efficient way to do it, but this ought to get the job done... Code: function get_all_but_last() {
[eluser]Aken[/eluser]
You can do so in your SQL query. Check out this Stack Overflow question.
[eluser]Alfonso[/eluser]
Another way to do it , just removing the last element of the array $records $query = $this->db->get('name_of_my_table'); $records = $query->result(); unset( $records[count($records)-1] );
[eluser]jmadsen[/eluser]
Code: SELECT * on large tables, this may not be the fastest way |
Welcome Guest, Not a member yet? Register Sign In |