See here. If the first parameter of find() method is no string, you have to bind the params through the criteria object.
$_GET validation question
#22
Posted 11 January 2010 - 03:48 PM
bas_vdl, on 11 January 2010 - 12:27 PM, said:
What is wrong:
CDbCommand failed to execute the SQL statement: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound
CDbCommand failed to execute the SQL statement: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound
echo $_GET['city']; //http://yii.dev/index/test/city/amsterdam.html prints amsterdam on the page
$criteria = new CDbCriteria;
$criteria->condition = 'City = :city';
$city = City::model()->find($criteria, array(':city' => $_GET['city']));
Try this:
$criteria = new CDbCriteria;
$criteria->condition = "City = :city";
$criteria->params = array(':city' => $_GET['city']);
$city = City::model()->find($criteria);

Help














