parameters and findbysql

I have this query


$seach=new seachuser();

$seach->attributes=$_POST['seachuser'];

$posts=Users::model()->findAllBySql("select usr_name  as cmp_name from users where usr_name 

like '%".$seach->usr_name."%'");

I want to know if there a way to pass the $seach->usr_name as parameter.

Use the second argument of the findAllBySql method: http://www.yiiframework.com/doc/api/CActiveRecord#findAllBySql-detail

$posts=Users::model()->findAllBySql("select usr_name as cmp_name from users where usr_name

like ‘%:keyword%’", array(’:keyword’=>$seach->usr_name));