YII Module inserting Multiple Rows

I’ve recently started working with Yii, so forgive the ignorance :)

I have an SQL query which returns multiple rows (array of arrays), i then want to insert those rows to DB:

$queryResults = $command->queryAll();

$model=new Campaigns();

foreach ($queryResults as $CActive) {

$model->setIsNewRecord(true);


$model->attributes=$CActive;

if($model->save($CActive)) {

echo "Good!";

}

the problem is even though i’m setting the model with new record it has a record of the previous PK (since it’s the same model).

do i need to create a new model for each row? (doesnt seem likely…)

Thanks as always, Danny

yes… u need to create new model…

and use functions like findByAttributes(),findAll()…other than sql query …

Thx!!