/** * (non-PHPdoc) * @see \Koldy\Db\Select::getQuery() */ protected function getQuery() { if ($this->searchTerm !== null) { // there is search term set, so we'll need to include this to where statements // but, there might be already some where statements in the query, so we'll create // new Where instance and we'll add that Where block with AND operator $where = Where::init(); if ($this->searchFields !== null) { foreach ($this->searchFields as $field) { $where->orWhereLike($field, "%{$this->searchTerm}%"); } } else { foreach ($this->getFields() as $field) { $where->orWhereLike($field['name'], "%{$this->searchTerm}%"); } } $this->where($where); } return parent::getQuery(); }