<?php
	require_once( $GLOBALS["site_root"] . "/includes/models/Member.inc.php" );

	class MembersModel {
		public function getLastRegisteredMembers() {
			$mm = new MemberModel();
			$query = sprintf( "select members.*,users.user_name from members,users
				where
					members.user_id=users.user_id and
					members.expires_tstamp>now() and
					not members.is_deleted and
					not users.is_deleted
					order by users.reg_tstamp desc
					limit 5" );
			$ds = FNTH_db_get_resultset( $query );
			$retval = array();
			foreach ($ds as $row) {
				$retval[]=$mm->prepareMember( $row );
			}
			return $retval;
		}

		public function getNumberOfMembers() {
			$query = sprintf( "select count(members.member_id) as num from members,users where
				members.user_id = users.user_id and
				not members.is_deleted and
				not users.is_deleted" );
			return FNTH_db_get_field( $query, "num" );
		}

		public function getMemberIds( $offset = 0 , $limit = 10 ) {
			$query = sprintf( "select members.member_id from members,users where
				members.user_id = users.user_id and
				not members.is_deleted and
				not users.is_deleted
				order by members.member_id
				offset %d limit %d" , $offset , $limit );
			return FNTH_db_get_column( $query , "member_id" );
		}
	}

?>
