![]() |
Get query results in model - 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: Get query results in model (/showthread.php?tid=58670) |
Get query results in model - El Forum - 07-04-2013 [eluser]rochellecanale14[/eluser] Hello guys just want to ask about models. I created a model called Entry_Model and I have two functions. One is to view all entries and the other one is to count. I did this by using a traditional query. I used this code: Code: $sql1 = "SELECT * FROM entries"; My problem is when i tries to get the result from my model and then passing thru the controller I got an error like this: Code: Fatal error: Call to a member function result_row() on a non-object in Entry_Controller: Code: public function index(){ Code: public function viewAllEntry(){ Code: foreach($countAllEntries->result_row() as $row){ echo $allRecord; //return error But when i try not to use a model it works. Here's what i did in my view. Code: $sqlCountEntry = "SELECT COUNT(*) AS entry FROM tbl_entries"; What's my error? Or is there another way to perform this? By the way I used tradtional query because as of now I am confused with the use of active query. Specially when I performing a join statement. Please help me guys. Thanks. Get query results in model - El Forum - 07-06-2013 [eluser]xeroblast[/eluser] $data['viewEntries'] = $this->db->query($sqlViewAllEntry)->result(); $data['countAllEntries'] = $this->db->query($sqlCountEntries)->row(); |