function search($params = false) { $order_by = $this->get_key(); $order_direction = 'ASC'; $inicial = 0; $total = MAXIMO_RESULTADOS_BUSCA; if ($params !== false) { if (isset($params['order_by'])) { $order_by = $params['order_by']; } if (isset($params['order_direction'])) { $order_direction = $params['order_direction']; } if (isset($params['inicial'])) { $inicial = $params['inicial']; } if (isset($params['total'])) { $total = $params['total']; } } $objs = array(); $this->db->select('p.id as id,u.nome as nome,u.id as id_usuario, username, email, telefone, endereco, data_nascimento, p.deleted as deleted,u.avatar as avatar '); $this->db->join('usuario u', 'u.id = p.id_usuario'); $this->db->distinct($this->key); $this->db->where('p.deleted', NAO); $this->db->order_by($order_by, $order_direction); $query = $this->db->get($this->table_name . ' p', $total, $inicial); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $professor = new Professor(); $professor->set_id($row->id); $professor->set_nome($row->nome); $professor->set_id_usuario($row->id_usuario); $professor->set_username($row->username); $professor->set_email($row->email); $professor->set_telefone($row->telefone); $professor->set_endereco($row->endereco); $professor->set_deleted($row->deleted); $professor->set_avatar($row->avatar); $professor->set_data_nascimento($this->datas->mysql_para_normal($row->data_nascimento)); array_push($objs, $professor); } } $query->free_result(); return $objs; }