[eluser]NateL[/eluser]
[quote author="David Johansson" date="1248611542"]
But you really need to use an ORDER BY statement!
In active record it would be:
Code:
$query = $this->db->select('id')->order_by('id', 'asc')->get_where('clients', array('id >' => $id), 1, 0);
if($query->num_rows == 1)
{
$next_id = $query->row()->id;
}
else
{
$next_id = FALSE;
}
[/quote]
Thanks for cleaning it up and putting it into CI Active Record for me
Now, I'm not doubting you - just curious why you
need to use ORDER BY ?
When you say "select by id greater than 5 limit 1" - it's pretty obvious to me it's going to look for the next highest id above 5, so why sort one result?