Reputation: 3750
I hope this isn't to vague, I am still a beginner to the idea of the MVC-L framework. I'm in the process of creating an Open-cart 1.5.1.3 module, and from what I can gather OC 1.5+ will call the install() function automatically from within you controller when you first install the a module (if you provide install() function that is). Where I'm having trouble is with actually calling a function (which creates a new database table) which is located in the model from my controller function install().
Here is the code I have already:
Controller : TrademeXml
public function install() {
$this->load->model('model/TrademeXml');
// Create table to store TradeMe ID
$this->model_model_TradmeXml->createModuleTables();
}
Model : TradmeXml
public function createModuleTables() {
$query = $this->db->query("CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "trademeID (tid INT(30), PRIMARY KEY(tid)");
}
The install function is called during the installation of the module, but I get the following error:
Fatal error: Call to a member function createModuleTables() on a non-object in D:\xampp\htdocs\store\admin\controller\module\TrademeXml.php
Upvotes: 1
Views: 6408
Reputation: 15151
$this->load->model('module/tradexml');
$this->model_module_tradexml->createModuleTables();
Upvotes: 4