第一个代码块抛出错误Fatal error: Class 'DboSource' not found
,而第二个代码块工作得很好。这打败了我,两者都使用同一行来保存创建的字段...块 1
public function add() {
if ($this->request->is('post')) {
$this->request->data['created'] = DboSource::expression('NOW()');
$this->EbayAccount->create();
if ($this->EbayAccount->save($this->request->data)) {
//$this->EbayAccount->id = $this->EbayAccount->getLastInsertID();
//$this->EbayAccount->saveField('created', DboSource::expression('NOW()'));
$this->Session->setFlash(__('The ebay account has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The ebay account could not be saved. Please, try again.'));
}
}
$this->set('userId', $this->Auth->user('id'));
}
第 2 座
public function add() {
if ($this->request->is('post')) {
//$this->request->data['created'] = DboSource::expression('NOW()');
$this->EbayAccount->create();
if ($this->EbayAccount->save($this->request->data)) {
$this->EbayAccount->id = $this->EbayAccount->getLastInsertID();
$this->EbayAccount->saveField('created', DboSource::expression('NOW()'));
$this->Session->setFlash(__('The ebay account has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The ebay account could not be saved. Please, try again.'));
}
}
$this->set('userId', $this->Auth->user('id'));
}