limit in mysql - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: limit in mysql (/showthread.php?tid=6629) |
limit in mysql - El Forum - 03-05-2008 [eluser]Unknown[/eluser] im still new about code igniter applications.... Due to my limited know-how.... My question goes like this... ::> $query = $this->db->get('mytable', 10, 20); which tells about the limit of displaying a record from the 'mytable' database.... but this is not working on me... i expect the code to display the first two record... but it seems i miss it... i made a code : $query = $this->db->get('mytable',2); which display the first two record... please comment my post.... i want to learn more about code igniter.... limit in mysql - El Forum - 03-05-2008 [eluser]Michael Wales[/eluser] Code: $query = $this->db->get(’mytable’, 10, 20); Code: SELECT * FROM `mytable` LIMIT 10, 20 Code: $query = $this->db->get(’mytable’,2) limit in mysql - El Forum - 03-06-2008 [eluser]Unknown[/eluser] but still the "SELECT * FROM `mytable` LIMIT 10, 20 " query you given to me still not work on me...... The query display none of records.... this is the query i made.. [which mean i sorted the table to its id in decending way] $this->db->order_by("id", "desc"); $query = $this->db->get('article',2); but if i gonna use $query = $this->db->get('article',0,2); > it display none of records. limit in mysql - El Forum - 03-07-2008 [eluser]xwero[/eluser] [quote author="Cyber Ghost" date="1204871545"]but still the "SELECT * FROM `mytable` LIMIT 10, 20 " query you given to me still not work on me...... [/quote] If you don't have more than 20 records in that table you won't get any result. limit in mysql - El Forum - 03-07-2008 [eluser]dark_lord[/eluser] I think I might go with xwero's answer.. may be your data in the table are insufficient to show 20 records.. limit in mysql - El Forum - 03-07-2008 [eluser]xwero[/eluser] [quote author="wish_bear" date="1204897606"]I think I might go with xwero's answer.. may be your data in the table are insufficient to show 20 records.. [/quote] I think you got the wrong idea the get method puts the limit before the offset which could confuse some people because in the (my)sql statement it's the other way around. Code: $this->db->get('table',10,20); Quote:SELECT * FROM table LIMIT 20,10So you need to have over 20 records. If you have 21 records you get one record as result. |