<?php
saxue_includedb();
class saxuememberscore extends saxueobjectdata {
		function saxuememberscore() {
				$this -> initvar( "id", SAXUE_TYPE_INT, 0, "流水ID", false, 11 );
				$this -> initvar( "uid", SAXUE_TYPE_INT, 0, "会员ID", false, 11 );
				$this -> initvar( "amount", SAXUE_TYPE_INT, 0, "积分数", false, 11 );
				$this -> initvar( "balance", SAXUE_TYPE_INT, 0, "积分余额", false, 11 );
				$this -> initvar( "time", SAXUE_TYPE_INT, 0, "流水日期", false, 10 );
				$this -> initvar( "aid", SAXUE_TYPE_INT, 0, "文章ID", false, 11 );
				$this -> initvar( "type", SAXUE_TYPE_INT, 0, "说明", false, 4 );
		} 
} 

class saxuememberscorehandler extends saxueobjecthandler {
		function saxuememberscorehandler( $_db = "" ) {
				$this -> saxueobjecthandler( $_db );
				$this -> basename = "memberscore";
				$this -> autoid = "id";
				$this -> dbname = "member_score";
		} 

		function addlog( $_data ) {
				if ( empty( $_data ) || !is_array( $_data ) || empty( $_data['uid'] ) || empty( $_data['amount'] ) ) {
						return false;
				} 
				$_newlog = $this -> create();
				$_newlog -> setvar( "id", 0 );
				$_newlog -> setvar( "uid", intval( $_data['uid'] ) );
				$_newlog -> setvar( "amount", intval( $_data['amount'] ) );
				$_newlog -> setvar( "balance", intval( $_data['balance'] ) );
				$_newlog -> setvar( "time", SAXUE_NOW_TIME );
				$_newlog -> setvar( "aid", intval( $_data['aid'] ) );
				$_newlog -> setvar( "type", intval( $_data['type'] ) );
				return $this -> insert( $_newlog );
		} 
}