如何使用Yii活动记录
编写此命令 INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;
答案 0 :(得分:-2)
$model->Yourmodel::model()->findByPk($key);
if($model){
$model->value = $newvalue;
}else{
$model = new Yourmodel();
$model->value = $newvalue;
}
if($model->save()){
// do somethings
}