сделал так но эт нифига не правильно
public function actionCreate()
{
$model = new Role;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Role']))
{
$model->attributes = $_POST['Role'];
if ($model->save())
{
if (isset($_POST['im_id']))
{
$command = Yii::app()->db->createCommand();
$maxOrderNumber = Yii::app()->db->createCommand()
->select('max(id) as max')
->from('t_role')
->queryScalar();
$max = $maxOrderNumber ;
foreach ($_POST['im_id'] as $check)
{
$Ids = $_POST['im_id'];
};
for ($i = 0; $i < count($Ids); $i++)
{
$command->insert('t_haspage', array(
'id_role' => $max, ////
'id_page' => (int) $Ids[$i], ////
));
}
}
$this->redirect(array('view', 'id' => $max));
}
}
$this->render('create', array(
'model' => $model,
));
}