Welcome Guest, Not a member yet? Register   Sign In
HMVC and db
#5

[eluser]qpixo[/eluser]
[quote author="riskk" date="1337688069"]I installed the codeigniter HMVC plugin and it's working fine for me but when I try to load method of module from other module I get the error

Here is my code:

Module billet:
Code:
class getcombo extends CI_Controller {
  public function  __construct()
  {
      parent::__construct();
  }

  public function index()
  {
      
  }

  public function semester()
  {                        
      parent :: StartAdmin();
      table_id = $this->db->select('table_id')->from('sys_tables')->where('table', 1)->get()->row()->table_id;

      return table_id;
  }
}

Module journal:
Code:
class journal extends MY_Controller {
  public function  __construct()
  {
      parent::__construct();
  }

  public function index()
  {
      parent :: StartAdmin();

      $this->load->module('billet/getcombo')->semester();
      return $this->getcombo->semester();
  }
}

And error
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: getcombo::$db

Filename: controllers/getcombo.php

Line Number: 30
Fatal error: Call to a member function select() on a non-object in /var/www/site.com/application/modules/billet/controllers/getcombo.php

The problem occur when I use
Code:
table_id = $this->db->select('table_id')->from('sys_tables')->where('table', 1)->get()->row()->table_id;
If load method directly it`s work fine

How to fix this problem.[/quote]

Why did you do a request DB in a Controller? Any reasons?
You're not applied the basic concept of MVC here...

Secondly with HMVC when calling others modules, you should only use modules::run();


Messages In This Thread
HMVC and db - by El Forum - 05-22-2012, 05:01 AM
HMVC and db - by El Forum - 05-22-2012, 05:09 AM
HMVC and db - by El Forum - 05-22-2012, 05:23 AM
HMVC and db - by El Forum - 05-22-2012, 06:38 AM
HMVC and db - by El Forum - 05-22-2012, 10:02 AM
HMVC and db - by El Forum - 05-22-2012, 12:42 PM
HMVC and db - by El Forum - 05-22-2012, 12:50 PM
HMVC and db - by El Forum - 05-22-2012, 09:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB