Passing Sp Parameter


While trying to call a sp with single argument using create command from model,it shows error like this.

"CDbCommand failed to execute the SQL statement: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound. The SQL statement executed was: CALL usp_search_employee(:criteria) ".The code is given below.


public function search($searchKey)



	//query builder

	$data = Yii::app()->db->createCommand("CALL usp_search_employee(:criteria)")



	return $data ;



public function actionIndex()


	$searchValue           = trim(CHttpRequest::getPost('txtName',''));

	$objSearch              = new SearchEmpDao();


	$findEmp                = $objSearch->search($searchValue);



Any ideas?

The first argument to queryAll() is $fetchAssociative, not the parameter array.

See here.

You probably want:

$data = Yii::app()->db->createCommand("CALL usp_search_employee(:criteria)")

    ->queryAll(true, array(':criteria'=>$searchKey));

Thanks.It worked.