Welcome Guest, Not a member yet? Register   Sign In
Active Record - Group By

The tried code:

        $this->db->order_by("last_modified_date", "desc");

        $query = $this->db->get();

Table structure:

id , document_id , content , last_modified_date


The design of the system means that when documents are updated, a actual new record is created with the same document_id and the updated content.

Now I need the documents displayed in a list, however if they are multiple documents with the same document_id (basically older versions of the file), only the latest version should be displayed. The current code outputs the first versions only, so this needs to be switched.

Is group_by the right method for this? Anyone with some experience can work out why its not working as intended, or am I just doing it wrong?

Theme © iAndrew 2016 - Forum software by © MyBB