如果以前未插入值,我想更新表中的值。这是我的代码-
function save_data($date, $game, $score) {
$criteria = new CDbCriteria;
$criteria->addCondition("date = '{$date}'");
$data = array("date" => $date,
"game" => $game,
"score" => $score);
$game_report = new GameReport();
$game_report->attributes = $data;
$game_report->save();
}
但即使我提供了日期条件,它也会继续插入重复值。为什么?如何更新而不插入重复值?