![]() |
DataMapper - View does not match Query - 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: DataMapper - View does not match Query (/showthread.php?tid=44391) |
DataMapper - View does not match Query - El Forum - 08-12-2011 [eluser]Genki1[/eluser] Hi WanWizard, What is the recommended way to pass a query result to a view? I'm not able to get the results I expect and would appreciate your insight. Here's what is happening: In my controller, I perform a $obj->get() and the $obj->result_count() correctly indicates the expected number of matching records. Manually running the sql from $obj->check_last_query() in phpMyAdmin also displays the expected records. So far, so good. Next, I pass that $obj to my view. Looping over the $obj, I get ALL the records in the table, not just the matching records I'm expecting. Why? Example: my_controller.php Code: $u = new User; my_view.php Code: foreach ($matching_records as $record): So, in the view, all the records are displayed, not the expected set of just 4 records found in my query. What is the recommended way to pass the result set to the view and to loop over it? |