Active Record "get()" with "limit()" and pagination/uri segment value displaying one too few results - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Active Record "get()" with "limit()" and pagination/uri segment value displaying one too few results (/showthread.php?tid=41746) |
Active Record "get()" with "limit()" and pagination/uri segment value displaying one too few results - El Forum - 05-16-2011 [eluser]fiddle-sticks[/eluser] Hi please can somebody tell me why I am only getting a result of 11 items instead of 12 on the first page (no 3rd uri segment) with the following code. Code: $limit = 12; Ps Im not sure if posted this in the right place because I couldnt find exactly where this shoul be posted. Regards Active Record "get()" with "limit()" and pagination/uri segment value displaying one too few results - El Forum - 05-16-2011 [eluser]Dan Storm[/eluser] Try using $this->db->last_query(); to verify that your SQL query is exactly as you expected. Additionally, try pasting the result from $this->db->last_query(); into phpMyAdmin and see if the results are as expected. Active Record "get()" with "limit()" and pagination/uri segment value displaying one too few results - El Forum - 05-16-2011 [eluser]fiddle-sticks[/eluser] yeah the query is fine - it ends in "LIMIT 12". But still I am only getting 11 pictures being displayed in my view. My view code goes roughly like this: Code: foreach($data->result() as $row): Active Record "get()" with "limit()" and pagination/uri segment value displaying one too few results - El Forum - 05-16-2011 [eluser]Dan Storm[/eluser] [quote author="fiddle-sticks" date="1305564729"]yeah the query is fine - it ends in "LIMIT 12". But still I am only getting 11 pictures being displayed in my view. My view code goes roughly like this: Code: foreach($data->result() as $row): You probably get 12 rows returned but your if condition: Code: if (@GETIMAGESIZE('template_images/' . $row->thumb_path)) Active Record "get()" with "limit()" and pagination/uri segment value displaying one too few results - El Forum - 05-16-2011 [eluser]fiddle-sticks[/eluser] But Ive got the same structure for two seperate views getting results from two seperate tables in the db. And the same error happens on both so Im guessing its a generic sort of problem with the code itself instead of the results. Im stumped Active Record "get()" with "limit()" and pagination/uri segment value displaying one too few results - El Forum - 05-16-2011 [eluser]Dan Storm[/eluser] The problem lies in your if condition. Try pulling it out of the foreach and just echo $row->thumb_path in your foreach loop and nothing else - you will see all twelve results. Active Record "get()" with "limit()" and pagination/uri segment value displaying one too few results - El Forum - 05-17-2011 [eluser]fiddle-sticks[/eluser] thanks I see what is wrong now. Some of the images were broken so the if statement would clean them out. pretty obvious in hindsight I suppose |