Hi,
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.
--------------------------------------
mymodel.php
**********
public function search($searchKey)
{
//query builder
$data = Yii::app()->db->createCommand("CALL usp_search_employee(:criteria)")
->queryAll(array(':criteria'=>$searchKey));
print_r($data);
return $data ;
}
--------------------------
mycontroller.php
*********
public function actionIndex()
{
$searchValue = trim(CHttpRequest::getPost('txtName',''));
$objSearch = new SearchEmpDao();
$findEmp = $objSearch->search($searchValue);
$this->render('ListEmp',array("list"=>$findEmp,));
}
----------------------------------------
Any ideas?
Page 1 of 1
Passing Sp Parameter
#3
Posted 20 February 2013 - 12:34 AM
Keith, on 19 February 2013 - 07:27 AM, said:
The first argument to queryAll() is $fetchAssociative, not the parameter array.
See here.
You probably want:
See here.
You probably want:
$data = Yii::app()->db->createCommand("CALL usp_search_employee(:criteria)")
->queryAll(true, array(':criteria'=>$searchKey));
Thanks.It worked.
Share this topic:
Page 1 of 1

Help












