A
A
Alexander2015-05-28 13:47:30
Yii
Alexander, 2015-05-28 13:47:30

How to search for text in two bd fields?

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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2015-05-28
@webinar

Maybe you need this:

$criteria->addSearchCondition('name_ru','петух');
$criteria->addSearchCondition('name_en','петух',true,'OR);

here is a link on the topic yiiframework.ru/forum/viewtopic.php?t=7672

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question