2012-12-25 50 views
0

我使用笨MVC和麪臨的一個奇怪的問題,創建控制器時,並嘗試在其構造函數加載模型

require_once("secure_area.php"); 
class posstatics extends Secure_area{ 
    function __construct(){ 
     $this->load->model('sale'); //at this i am getting the error saying undefined prop 
    } 
} 

的secure_area.php文件擴展開發項目該是CI_Controller同樣是工作的應用程序的其他部分,但這一類創建滋擾我:(

回答

5

首先,你不需要手動要求,笨自動進行的照顧。

假設Secure_area前往往CI_Controller,你需要調用超級方法。

class posstatics extends Secure_area{ 
    function __construct(){ 
     parent::__construct(); 
     $this->load->model('sale'); //at this i am getting the error saying undefined prop 
    } 
} 
+0

Thaks man ..你救了我的時間:-) – ravisoni