1

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

tereško
  • 58,060
  • 25
  • 98
  • 150
JasonMortonNZ
  • 3,752
  • 8
  • 34
  • 56

2 Answers2

4
$this->load->model('module/tradexml');
$this->model_module_tradexml->createModuleTables();
Jay Gilford
  • 15,141
  • 5
  • 37
  • 56
0

I was missing this...

public function index() {
        $this->install();
hram908
  • 374
  • 6
  • 15