Adi*_*att 8 controller cron-task cakephp-2.0 cakephp-2.3
对于CakePHP 2.3.8如何在CronController.php中调用Another Controller函数
有任何想法吗?
Adi*_*att 34
以下是代码:
App::import('Controller', 'Products'); // mention at top
// Instantiation // mention within cron function
$Products = new ProductsController;
// Call a method from
$Products->ControllerFunction();
Run Code Online (Sandbox Code Playgroud)
希望它有所帮助!
我参考了手册来找到解决方案。
public function that_controller_function_you_are_writing () {
# this is cakes way of running required
App::import('Controller', 'Users');
$UsersController = new UsersController;
# now you can reference your controller like any other PHP class
$UsersController->that_function_you_needed();
}
Run Code Online (Sandbox Code Playgroud)
这是链接:http : //book.cakephp.org/2.0/en/core-utility-libraries/app.html
| 归档时间: |
|
| 查看次数: |
33718 次 |
| 最近记录: |