private function query($instance) { $model = new wpl_users(); $data = $instance['data']; $this->start = 0; $this->limit = $data['limit']; $this->orderby = $data['orderby']; $this->order = $data['order']; $where = array('sf_tmin_id' => 1, 'sf_select_access_public_profile' => 1, 'sf_select_expired' => 0); if (trim($data['user_type']) and $data['user_type'] != '-1') { $where['sf_select_membership_type'] = $data['user_type']; } if (trim($data['membership']) and $data['membership'] != '') { $where['sf_select_membership_id'] = $data['membership']; } if (trim($data['user_ids'])) { $where['sf_multiple_id'] = trim($data['user_ids'], ', '); } if (isset($data['random']) and trim($data['random']) and trim($data['user_ids']) == '') { $query_rand = "SELECT p.`id` FROM `#__wpl_users` AS p WHERE 1 " . wpl_db::create_query($where) . " ORDER BY RAND() LIMIT " . $this->limit; $results = wpl_db::select($query_rand); $rand_ids = array(); foreach ($results as $result) { $rand_ids[] = $result->id; } $where['sf_multiple_id'] = implode(',', $rand_ids); } $model->start($this->start, $this->limit, $this->orderby, $this->order, $where); return $model->query(); }