Class FramingPartnersController extends CroogoAppController {
public $components = array('Paginator', 'Session');
public $uses = array('FramingPartner');
public function index() {
$test = 'This is Framing Partners Index';
$this->set(compact('test'));
}
public function profile() {
if(!empty($this->request->data)){
if ($this->request->is('post')) {
$this->FramingPartner->create();
if ($this->FramingPartner->save($this->request->data)) {
$this->Session->setFlash(__d('croogo', 'The profile has been saved'), 'flash', array('class' => 'success'));
$this->redirect(array('action' => 'frames'));
} else {
$this->Session->setFlash(__d('croogo', 'The profile could not be saved. Please, try again.'), 'default', array('class' => 'error'));
}
}
}
}
public function frames() {
$test = 'This is Framing Partners frames';
$this->set(compact('test'));
}
}
我有两个不同的表,每个表用于配置文件和帧,并希望从上面提到的操作将数据发送到各自的表。 简而言之,来自配置文件的数据应该转到配置文件表,而来自框架的数据应该转到框架表。
答案 0 :(得分:1)
public function frames(){
if(!empty($this->request->data)){
if ($this->request->is('post')) {
$this->loadModel('Frame');
$this->Frame->create();
if ($this->Frame->save($this->request->data)) {
$this->Session->setFlash(__d('croogo', 'The profile has been saved'), 'flash', array('class' => 'success'));
/* $this->redirect(array('action' => 'frames'));*/
} else {
$this->Session->setFlash(__d('croogo', 'The profile could not be saved. Please, try again.'), 'default', array('class' => 'error'));
}
}
}
}
通过这种方式,我从不同的控制器加载不同的模型,即从FramingPartnersController加载帧模型。
明确地说,我正在加载Frame Model,它会自动加载Frame表。