我想从另一个控制器加载一个功能。这是我的结构:从另一个控制器使用控制器CodeIgniter和HMVC
- modules
--orderpages
---controllers
----WebshopCore.php
----WebshopController.php
在WebshopController.php我的功能insertItemInCart被调用。但是当我想从另一个控制器执行一个函数时,它会崩溃。
class WebshopController extends MX_Controller {
public function __construct() {
parent::__construct();
$this->load->module('orderPages/WebshopCore');
}
function insertItemInCart(){
$partId = $this->input->post('partId');
$quantity = $this->input->post('quantity');
$output = $this->WebshopCore->getPickLocations($partId,$quantity);
}
}
我WebshopCore:
class WebshopCore extends MX_Controller {
public function __construct() {
parent::__construct();
}
public function getPickLocations($partId,$amount){
$result = "test";
return $result;
}
}
错在何处?我不明白这一点
解决办法:
$output = modules::load('orderPages/WebshopCore/')->getPickLocations($partId,$quantity);
IMO,调试:'的var_dump($这个 - > WebshopCore, __FILE __.__ LINE __);紧接在'$ output = ....'之前。 Yopu应该看到WebshopCore对象。 –
@RyanVincent NULL字符串(107)“/Applications/AMPPS/www/cart.local/application/modules/orderPages/controllers/WebshopController.php19”这就是我回到 – da1lbi3
@RyanVincent我已经做到了 – da1lbi3