How To Run Validation While Using Cdbcommandbuilder::createmultipleinsertcommand()

I am using CDbCommandBuilder::createMultipleInsertCommand() to create a multiple insert CDbCommand. But how can I run validation before saving it?

For single insert commands, the validation is done inside save() method (I think).


// Controller

if (isset($_POST[‘ProductBrand’])) {

[indent]$model->attributes = $_POST[‘ProductBrand’];[/indent]

[indent]if ($model->saveRows())[/indent]



// Model

public function saveRows()


[indent]$builder = Yii::app()->db->schema->commandBuilder;

$names = explode(’, ', $this->attributes[‘name’]);

$type_id = $this->attributes[‘type_id’];

$attributes = array();

foreach ($names as $name) :

$attributes[] = array(‘name’ => $name, ‘type_id’ => $type_id);


$command = $builder->createMultipleInsertCommand(

‘vwa_product_brand’, $attributes);

if ($command->execute()) :

[indent]return TRUE;[/indent]


return FALSE;[/indent]


Any help is appreciated.

got it