![]() |
model and database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: model and database (/showthread.php?tid=65441) Pages:
1
2
|
model and database - davy_yg - 06-12-2016 I have a quick question regarding the connection between model in CI and database. for example: This is my table: giondacms (database name) ------------------------- pages (table name) pages_name create_date pages_order model/pages_model.php PHP Code: public function insert_pages() Looking at my database and table, is there anything wrong with my pages_model.php ? Thanks in advance, Davy RE: model and database - skunkbad - 06-12-2016 None of the fields you are trying to insert are in your table. If you want to insert "title", there has to be a "title" field in your table. Same goes for date, order, and content. Right now you show your only 3 fields as "pages_name", "create_date", and "pages_order" Why not use those in your insert? RE: model and database - arma7x - 06-12-2016 (06-12-2016, 08:25 AM)davy_yg Wrote: I have a quick question regarding the connection between model in CI and database. for example: Please follow the tutorial guide at here and read other section too. The real problem is you keep ignoring the documentation. RE: model and database - davy_yg - 06-12-2016 Thanks for advice. I fix some stuff: controllers/cpages.php PHP Code: public function __construct() I get this error that I do not know how to fix: A PHP Error was encountered Severity: Notice Message: Undefined property: pages_model::$load Filename: libraries/Form_validation.php Line Number: 147 Backtrace: File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\models\pages_model.php Line: 11 Function: __construct File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\controllers\Cpages.php Line: 68 Function: model File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\index.php Line: 315 Function: require_once Any idea how to fix the error? RE: model and database - arma7x - 06-12-2016 PHP Code: public function insert_pages() RE: model and database - davy_yg - 06-12-2016 Hello, I still receive this error message: A PHP Error was encountered Severity: Notice Message: Undefined property: pages_model::$load Filename: libraries/Form_validation.php Line Number: 147 Backtrace: File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\models\pages_model.php Line: 11 Function: __construct File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\controllers\Cpages.php Line: 68 Function: model File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\index.php Line: 315 Function: require_once controllers/cpages.php PHP Code: public function addpages() models/pages_model.php PHP Code: public function insert_pages() views/add_pages.php PHP Code: <form action="submitpages" method="post"> giondacms (database) pages (table) 1 pages_name 2 create_date 3 pages_order How to fix the error? RE: model and database - InsiteFX - 06-12-2016 A Model Class and its filename must have the first letter upper case! RE: model and database - davy_yg - 06-12-2016 I change the model class name and filename into uppercase. models/Pages_model.php PHP Code: class Pages_model extends CI_Controller { I still have this error appears: A PHP Error was encountered Severity: Notice Message: Undefined property: Pages_model::$load Filename: libraries/Form_validation.php Line Number: 147 Backtrace: File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\models\Pages_model.php Line: 11 Function: __construct File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\controllers\Cpages.php Line: 68 Function: model File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\index.php Line: 315 Function: require_once RE: model and database - salain - 06-12-2016 Hi, Model extends the base model CI_Model not the controller!! RE: model and database - davy_yg - 06-14-2016 Hello, I am trying to fix this input form so that it could capture information and store it in the database. Yet, even after filling this information and press enter it still does not moves to the database I wonder why? Gionda CMS Pages create_date pages_name pages_order Pages Name: Home Create Date: 552016 Order: 5 Content: Lorem Ipsum ------------------------------------ Thank you for filling the information. It has been successful. Pages Name: Home Create Date: 552016 Order: 5 Content: Lorem Ipsum ------------------------------- views/add_pages.php PHP Code: Code: <form action="submitpages" method="post"> controllers/cpages.php PHP Code: Code: public function addpages() models/pages_model.php PHP Code: Code: public function insert_pages() |