public function search($query) { $has_fields = FALSE; $object = $this->model->object(); foreach ($this->labels as $key => $value) { if (in_array($key, $this->ignore_fields)) { continue; } if (array_key_exists($key, $object)) { if (!$has_fields) { $this->model->where_open(); $has_fields = TRUE; } $this->model->or_where($key, 'LIKE', '%' . $query . '%'); } } if ($has_fields) { $this->model->where_close(); } }