我需要为列生成唯一值。我想增加表中最后插入的值。
我试过这个,但无济于事
if($this->request->is('post')){
$code = $this->Department->find('first', array(
'fields' => 'Department.code',
'order' => 'Department.code DESC'
));
$code += 1;
$this->data['Department']['code'] = $code;
if($this->Department->save($this->request->data)){
$this->Session->setFlash('New department added.');
$this->redirect(array('action' => 'add'));
}
}
谢谢!