public function query($params) { $sql = "SELECT *, 'CPT4' as code_type FROM cpt_codes WHERE isRadiology = '1'"; if (isset($params->onlyActive) && $params->onlyActive) { $sql .= " AND active = '1' "; } if (isset($params->isRadiology) && $params->isRadiology) { $sql .= " AND isRadiology = '1' "; } $this->c->reset(); $sql .= ' AND (code LIKE ' . $this->c->where($params->query . '%') . ' OR code_text LIKE ' . $this->c->where('%' . $params->query . '%') . ' OR code_text_short LIKE ' . $this->c->where('%' . $params->query . '%') . ' OR code_text_medium LIKE ' . $this->c->where('%' . $params->query . '%') . ')'; $records = $this->c->sql($sql)->all(); return array('total' => count($records), 'data' => array_slice($records, $params->start, $params->limit)); }