我以前从未这样做过,所以我需要一些输入。
代码(一般):
$cofig = Configure::read('config');
if ($config['stuff'] == 1){
$this->Session->setFlash('it is already done this month');
$this->redirect('/to/some/where');
}
elseif ($config['stuff'] == 2){
$this->Session->setFlash('it is already running');
$this->redirect('/to/some/where');
}
else {
SomeComponent::SomeFunction(); //this I need to launch in background while user continues further
$this->Session->setFlash('you have launched it');
$this->redirect('/to/some/where');
}
“SomeComponent”包含几个功能。我需要在免费中启动一个特定的函数“SomeFunction()”,同时用户继续。
函数“SomeComponent::SomeFunction()”生成一堆 pdf,与数据库交互并使用 Cakephp 特定的方法'n'crap 来完成所有这些。用户通过数据库接收输出,所以我不需要从函数本身检索它。
所以我不清楚哪种方法可以做到这一点,哪种方法最好使用,以及每种方法的缺点是/可能是什么(特别是安全问题)。
我希望我以一种可以理解的方式解释了一切。如果你已经读到这里 - 谢谢。