How to use 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: How to use Model (/showthread.php?tid=3663) |
How to use Model - El Forum - 10-16-2007 [eluser]Unknown[/eluser] Is there any one know how to use models to access the database, I wrote the following code, is there anything wrong about it. Code: <?php The above gives the following error.... [error] A PHP Error was encountered Severity: Notice Message: Undefined property: Blogmodel::$load Filename: test/blogmodel.php Line Number: 24 Fatal error: Call to a member function database() on a non-object in C:\wamp\www\CodeIgniter\system\application\models\test\blogmodel.php on line 24 [\error] Plz help me...., actually I want to insert in database using models. If you have the code for inserting in database using model,view and controller, plz send it to me. How to use Model - El Forum - 10-16-2007 [eluser]nmweb[/eluser] IT seems fine. Try enclosing your code between [ code ] and [ / code] in the future. It improves readability. Second thing, your function reads get_last_ten_entries() but you use Code: $query = $this->db->get(’entries’,3); How to use Model - El Forum - 10-16-2007 [eluser]xwero[/eluser] What is the code you use to call this model, there will be the mistake i think. How to use Model - El Forum - 10-16-2007 [eluser]Matthew Pennell[/eluser] You only have one underscore in your constructor function, that might be causing a problem. How to use Model - El Forum - 10-16-2007 [eluser]Michael Wales[/eluser] You may also be having an issue with using $this in your update_entry() method. I do believe the $this object includes a lot more than you are expecting (such as the parent controller's name). You end up passing column names to the database that don't exist. Change your code to: Code: function insert_entry() |