我是 cakephp 的新手,我想在我的控制器中导入控制器,所以我使用下面的语法。这是我在其中导入用户控制器的控制器:
users_controller.php
function api_work(){ $data = $this->User->find('all'); $this->set('data' , $data); }
播放控制器.php
function api_show()
{
$this->layout= false;
App::import('Controller', 'Users');
$Users = new UsersController;
$Users->constructClasses();
$data = $Users->api_work();
pr($data); //it not display anything and shows error like undefined varia
ble
}
控制器已成功导入。问题是如何从 api_work() 函数返回数据?