While trying to insert new entry into auth_assignment table I am getting following error CDbCommand failed to execute the SQL statement: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens. The SQL statement executed was: INSERT INTO auth_assignment (itemname, userid, bizrule, data) VALUES(:itemname,:userid, :bizrule, :data)
Following is my code
public function actionCreate()
{
$user=new User;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['User']))
{
$user->setScenario('create');
$user->attributes=$_POST['User'];
if($user->save())
{
//*********************************************************************
$connection=Yii::app()->db;
$acID = $user->accountID;
if($user->accessLevel == 0)
{
$sql="INSERT INTO auth_assignment (itemname, userid, bizrule, data) VALUES(:itemname,:userid, :bizrule, :data)";
$command=$connection->createCommand($sql);
$command->bindParam('superadmin',$itemname,PDO::PARAM_STR);
$command->bindParam('hello',$userid,PDO::PARAM_STR);
$command->bindParam('',$bizrule,PDO::PARAM_STR);
$command->bindParam('',$data,PDO::PARAM_STR);
$command->execute();
}
if($user->accessLevel == 1)
{
$sql="INSERT INTO auth_assignment (itemname, userid, bizrule, data) VALUES(:itemname,:userid, :bizrule, :data)";
$command=$connection->createCommand($sql);
$command->bindParam('admin',$itemnamename,PDO::PARAM_STR);
$command->bindParam('hello',$userid,PDO::PARAM_STR);
$command->bindParam('',$bizrule,PDO::PARAM_STR);
$command->bindParam('',$data,PDO::PARAM_STR);
$command->execute();
}
if($user->accessLevel == 2)
{
$sql="INSERT INTO auth_assignment (itemname, userid, bizrule, data) VALUES(:itemname,:userid, :bizrule, :data)";
$command=$connection->createCommand($sql);
$command->bindParam('Authenticated',$itemname,PDO::PARAM_STR);
$command->bindParam('hello',$userid,PDO::PARAM_STR);
$command->bindParam('',$bizrule,PDO::PARAM_STR);
$command->bindParam('',$data,PDO::PARAM_STR);
$command->execute();
}
//else
// return;
//*********************************************************************
$user->saveAttributes(array('creationTime' => date("Y-m-d H:i:s")));
$this->redirect(array('view','id'=>$user->accountID));
}
}
$this->render('create',array(
'user'=>$user,
));
}