read_replica = $this->load->database('savvy_replica', TRUE); } public function get_assigns_point_records( $filters = [], $limit = null, $offset = null ) { $numeric_array = [ 'from_points' => 'points >=', 'to_points' => 'points <=' ]; $in_list = ['email', 'firstname', 'lastname']; $this->read_replica->select([ 'id', 'username', 'firstname', 'lastname', 'points', '\'\' AS ACT', ]); $this->read_replica->from('members'); $this->read_replica->where('id > 0'); foreach($filters as $key => $val) { if (in_array($key, $in_list)) { $this->read_replica->like('lower(' . $key . ')', strtolower($val)); } else if (array_key_exists($key, $numeric_array)) { $this->read_replica->where($numeric_array[$key], $val); } } if ($limit) { $this->read_replica->limit($limit, $offset); $this->read_replica->order_by('id ASC'); } return $this->read_replica->get()->result_array(); } }