title: Yii Counting records in model
body: <p>In my web  application I want to print the no of records  for a particular criteria   . But the output I am getting is  0 , although there are many  records for the matching condition.
  This code is inside a view of another model . "$data" belongs to that model </p>
  
  <p>My code  I implemented.</p>
  
  <pre><code>$temp=CHtml::encode($data-&gt;name);
  
          $find=ConsumerRequest::model()-&gt;findAllByAttributes(array('requested_vegetable'=&gt;$temp));
          $count = count($find);
         echo $count;
  </code></pre>
  
  <p>How should I resolve this?</p>