나는 창문에서 뛰어 내리기 전에 누군가 이걸 가지고 나를 도울 수 있기를 바랍니다. 나는이 시간에 몇 시간을 보냈고 내가 뭘 잘못하고 있는지 모른다.모듈에서 모델을로드 할 수없는 이유는 무엇입니까? [codeigniter 2.1.2에서 HMVC 사용]
기본적으로 HMVC를 CodeIgniter 2.1.2에 설치했는데 모든 것이 잘 작동하지만 표준 컨트롤러에서 모델을로드하는 것과 같은 방식으로 모델을로드 할 수 없습니다. 오래된 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
는 단계별 지침에 따라 :
나는이 오류 모델을로드하기 위해 노력하고있어 매 시간
. modules 폴더 옆에 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'] = 배열 ('session', 'database', 'form_validation', 'email', 'redux_auth'); 하나의 모델에서 언급 한 데이터베이스를로드하려고 시도했지만 잘 작동하지 않았습니다./HMVC 코어에 몇 가지 버그가있을 수 있습니까? – Pavel