[eluser]Unknown[/eluser]
Hello everyone,
Code:
public function getComments($minID = NULL, $maxID = NULL, $filter_select = TRUE, $limit = 10){
if($filter_select)
$this->db->select('ID, user, parent, comment, state');
if($minID)
$this->db->where('ID >', $minID);
if($maxID)
$this->db->where('ID <', $maxID);
$this->db->order_by("ID", "desc");
$this->db->limit($limit);
return $this->db->get('comments')->result_array();
}
i'm using code above in a model, the problem is that results are not ordered by ID descending.
I've seen that changing the line from
Code:
$this->db->order_by("ID", "desc");
to
Code:
$this->db->order_by("ID2", "desc");
gives error (ID2 doesn't exist) and the query string is this:
Code:
SELECT `ID`, `user`, `parent`, `comment`, `state` FROM (`comments`) ORDER BY `ID` asc, `ID2` desc LIMIT 10
so i'm thinking that the original version gives this query:
Code:
SELECT `ID`, `user`, `parent`, `comment`, `state` FROM (`comments`) ORDER BY `ID` asc, `ID` desc LIMIT 10
and of course that works but it doesn't order ID descending as I asked.
Is something i did wrong or is this a bug?
Regards
EDIT: After a while it worked :/ Sorry for posting