Example #1
0
 /**
  * Add inner join with criteria.
  *
  * @param \yii\db\Query $query Query instance
  * @param string $attribute Serched attribute name
  * @param string $relation Relation name
  * @param string $targetAttribute Target attribute name
  * @param boolean $partialMatch matching type
  */
 protected function addWithCondition($query, $attribute, $relation, $targetAttribute, $partialMatch = false)
 {
     $value = $this->{$attribute};
     if (trim($value) === '') {
         return;
     }
     if ($partialMatch) {
         $query->innerJoinWith([$relation])->andWhere(['like', $targetAttribute, $value]);
     } else {
         $query->innerJoinWith([$relation])->andWhere([$targetAttribute => $value]);
     }
 }