CodeIgniter Forums
problem with active record - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: problem with active record (/thread-45647.html)



problem with active record - El Forum - 09-29-2011

[eluser]Unknown[/eluser]
I'm using active records in all retrieve data from database, but some queries I do with active record has troubles, generally don't bring the last record...

for example

I have 5 records in my database with this idCategory

I have this query by active record

$this->db->where('idCategory','1');
$this->db->where('status','1');
$this->db->order_by('dateHour','desc');
$query = $this->db->get('news',10,$offset);
$data['news'] = $query->result();

That should generate this sql below

SELECT * FROM news WHERE idCategory = 1 and status = 1 order by dateHour desc

BUT, when a call the controller that has this query(active record), it bring to me only 4 records(don't bring me the last)

AND when I execute the sql normal in the database, bring me exactly what I want, the 5 records