if (Yii::app()->params['COMPAT3']===true && $this->scenario==='insert') {
$table = $this->tableName();
$sec = get_class($this).'Seq';
$db = Yii::app()->db;
$sql =<<<EOP
SELECT MAX(id) AS max FROM {$table}
EOP;
$cmd = $db->createCommand($sql);
$rd = $cmd->query();
$rs = $rd->read();
if (isset($rs['max'])) {
if ($sec::model()->exists()) {
$sql = "UPDATE {$table}_seq SET id={$rs['max']}";
}
else {
$sql = "INSERT INTO {$table}_seq (id) VALUES ({$rs['max']})";
}
$cmd = $db->createCommand($sql);
$cmd->execute();
}
}You might notice the Yii::app()->params['COMPAT3']===true , which is just a flag to indicate if we need to have both versions in parallel.

Help













