插入表1
('id','name','cust_id','add')
值('5','RENJITH','5','2012-08-04 15:07:38')
在重复键更新'cust_id'='5'的情况下'table1.id'IN('1','2','3')
使它在cakephp?
最佳答案
这样的事情应该在模型类中起作用:
//check if key duplikates
$duplicate = $this->find('first', array('conditions' => array('Model1.id' => 5)));
if($duplicate) {
$this->updateALL(array('Model1.cust_id' =>5), array('Model1.id' => array(1,2,3)));
} else {
$data['Model1'] = array('Model1.id' = 5, 'Model1.name' => 'RENJITH','Model1.cust_id' => 5, 'Model1.add' => strtotime('2012-08-04 15:07:38'));
$this->create();
$this->save($data);
}