A
A
Alexander2015-05-28 13:03:53
Yii
Alexander, 2015-05-28 13:03:53

How to pull data from a field using text?

public function searchByName(){
    $criteria = new CDbCriteria;
      $criteria->condition = "name_ru = петух";
    return new CActiveDataProvider($this, array(
      'criteria'=>$criteria,
      ));
  }

if instead of name = rooster I write id=2, then I get all the rules, but I don’t want to by name. Why and how to fix the error?
This is the error that comes out CDbCommand failed to execute the SQL query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'rooster' in 'where clause'. The SQL statement executed was: SELECT COUNT(*) FROM `ref_mahala` `t` WHERE name_ru = cock

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
George, 2015-05-28
@kentuck1213

public function searchByName(){
    $criteria = new CDbCriteria;
    $criteria->compare('name_ru ',"петух",true);
    return new CActiveDataProvider($this, array(
      'criteria'=>$criteria,
      'pagination'=>array(
        'pageSize'=> 999,

      )
    ));
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question