public static function list_by_code($code, $limit = 10, $offset = 0) { global $mysqli; $config = new Config(); $code = sanitize_input($code); $sql = "SELECT `id` FROM `{$config->database->{$config->site_identifier}->prefix}invites` WHERE `code` = {$code}"; // Limit string $limit = sanitize_input($limit); $sql .= " LIMIT {$limit}"; // Offset string $offset = sanitize_input($offset); $sql .= " OFFSET {$offset}"; $query = mysqli_query($mysqli, $sql); // Loop through invite ids, fetching objects $invites = array(); while ($query && ($result = mysqli_fetch_assoc($query))) { $invites[] = Invite::get_by_id($result['id']); } return $invites; }
public function invites($limit = 10, $offset = 0) { global $mysqli; $config = new Config(); $sql = "SELECT `id` FROM `{$config->database->{$config->site_identifier}->prefix}invites` WHERE `user_id` = {$this->id} ORDER BY `id` DESC"; // Limit string $limit = sanitize_input($limit); $sql .= " LIMIT {$limit}"; // Offset string $offset = sanitize_input($offset); $sql .= " OFFSET {$offset}"; $query = mysqli_query($mysqli, $sql); $invites = array(); while ($query && ($result = mysqli_fetch_assoc($query))) { $invites[] = Invite::get_by_id($result['id']); } return $invites; }