Welcome Guest, Not a member yet? Register   Sign In
MySQL query with LIMiT
#1

[eluser]Dennis Geus[/eluser]
Hi,

I've found something strange in my query results and I can't find out what I'm doing wrong.

For this project I need to display 20 records with status open.

So when I type in phpmyadmin or heidisql
Code:
select * from orders where closed=0 order by number LIMIT 0, 20
It gives me 20 items
569A 2011-05-18
569A 2011-05-18
568B 2011-05-17
567A 2011-05-16
566F 2011-05-16
565A 2011-05-16
564W 2011-05-16
563A 2011-05-16
562A 2011-05-16
561A 2011-05-12
560A 2011-05-12
559A 2011-05-12
556A 2011-05-10
554A 2011-05-09
553F 2011-05-09
552W 2011-05-09
551A 2011-05-05
550A 2011-05-05
549A 2011-05-04
548A 2011-05-02

But when I do it in CI like this
Code:
$this->db->select('*');
$this->db->from('orders');
$this->db->where('closed', 0); //only open
$this->db->order_by(number, 'DESC');
$this->db->limit(20, 0);
$query = $this->db->get();
if ($query->num_rows() > 0) {
foreach($query->result() as $row) {
  $this->table->add_row(
          $row->number,
          $row->date
);
}
It returns only 10 items:
569A 2011-05-18
568B 2011-05-17
566F 2011-05-16
564W 2011-05-16
562A 2011-05-16
560A 2011-05-12
556A 2011-05-10
553F 2011-05-09
551A 2011-05-05
549A 2011-05-04

What am I missing here?




Theme © iAndrew 2016 - Forum software by © MyBB