我希望有人能幫助我這個人之前我跳下窗口。我花了幾個小時在這一個,不知道我在做什麼錯。爲什麼我無法在模塊中加載模型? [在笨2.1.2使用HMVC]
基本上,我在笨2.1.2安裝HMVC,一切工作正常,但由於某種原因無法加載模型我做它的標準控制器相同的方式。在舊的codeigniter 1.7.1中,我可以簡單地通過調用$ this-> load-> model('my_model')來使用它,但現在我不能?!
我試圖加載模式,我得到這個錯誤每一個時間:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Special_cart::$db
Filename: core/Model.php
Line Number: 51
我已經安裝了它按照指示一步一步。我在模塊文件夾旁邊獲得third_party。在模塊我已經存儲了這樣幾個模塊:
modules
--boxes
----controller
----models
----views
我調用模塊在我的代碼是這樣的:
<?=modules::run('boxes/special_cart/index');?>
我模塊控制器代碼如下所示:
class Special_cart extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
if ($this->session->userdata('cart'))
{
# get product id's and each quantity
$cart_product_list = array_count_values($this->session->userdata('cart'));
# get list of product_id
$product_list = array_keys($cart_product_list);
# get product details
$this->load->model('productmodel');
$this->load->model('stockmodel');
$cart_products = $this->productmodel->cart_get_products_details($product_list);
$final_cart_array = array();
foreach($cart_products as $cart_product){
$product_stock = $this->stockmodel->view_product_stock($cart_product["id"]);
if(empty($product_stock) || $product_stock["UNITS"]<=0)
$cart_product["UNITS"] = 0;
else{
if($cart_product_list[$cart_product["id_web"]]>$product_stock["UNITS"])
$cart_product["UNITS"] = $product_stock["UNITS"];
else{
$cart_product["UNITS"] = $cart_product_list[$cart_product["id_web"]];
}
}
$final_cart_array[] = $cart_product;
}
$refresh_cart_array = array();
foreach($final_cart_array as $cart_product){
for($i=1;$i<=$cart_product["UNITS"];$i++){
$refresh_cart_array[] = $cart_product["id_web"];
}
}
$this->load->view("special_cart",array(
'refresh_cart_array' => $refresh_cart_array,
'final_cart_array' => $final_cart_array
));
} else {
$this->load->view("special_cart",array(
'refresh_cart_array' => NULL,
'final_cart_array' => NULL
));
}
}
}
我已經試過互聯網上找到每一個可能的解決方案 - 他們沒有工作.... 我希望你明白我的問題,但如果你需要一些進一步的解釋,請叫我。誰能幫忙?
這是我在我的配置文件:$ autoload ['libraries'] = array('session','database','form_validation','email','redux_auth');.我也嘗試加載你在單個模型中提到的數據庫,但是沒有工作:/ HMVC內核中可能存在一些錯誤? – Pavel