<?php
/**
 * ClassMst Entity
 * $Id: ClassMst.inc,v 1.1 2016/9/21 12:59:25 AIMS Exp $
 * @author wanggb
 * @package jp.fishow.entity
 * @access public
 */
class ClassMst extends CompassDynamicData
{
	var $school_id;
	var $grade_id;
	var $class_no;
	var $title;
	var $member_count;
	var $manager_id;
	var $delete_flg;
	

	/**
	 * 
	 * 
	 * @access public
	 * @param mixed class_mst
	 */
	function constructor($record)
	{
		parent::constructor($record);

		$this->school_id      = $record["school_id"];
		$this->grade_id   = $record["grade_id"];
		$this->class_no      = $record["class_no"];
		$this->title   = $record["title"];
		$this->member_count      = $record["member_count"];
		$this->manager_id   = $record["manager_id"];
		$this->delete_flg = $record["delete_flg"];
	}

	/**
	 * 
	 * @access public
	 * @static
	 * @param array 
	 * @return array Entity
	 */
	public static function getList($w_param = null, $orderkey = null, $direction = "ASC", $offset = null, $limit = null)
	{
		if ($w_param == null) {
			$w_param = array();
			$w_param["delete_flg"] = "false";
		}

		return CompassDBHandler::getList("ClassMst", "class_mst", $w_param, $orderkey, $direction, $offset, $limit);
	}

	/**
	 * 
	 * @access public
	 * @static
	 * @param array 
	 * @return array Entity
	 */
	public static function getListCount($w_param = null)
	{
		if ($w_param == null) {
			$w_param = array();
			$w_param["delete_flg"] = "false";
		}
		$db = CompassDBManager::getInstance();
		$result = $db->doSelect("class_mst", $w_param, null, null, null, null, "count(*) as count");

		return $result[0]["count"];
	}

	/**
	 * 
	 */
	public static function getById($id)
	{
		// delete_flg
		$param = array();
		$param["delete_flg"] = false;

		return CompassDBHandler::getById("ClassMst", "class_mst", $id, $param);
	}

	
	/**
	 * 
	 * DynamicData
	 * @access public
	 * @return int 
	 */
	public function save()
	{
		$v_param = array();

		ParamUtil::copyObj2Array($v_param, $this, "school_id");
		ParamUtil::copyObj2Array($v_param, $this, "grade_id");
		ParamUtil::copyObj2Array($v_param, $this, "class_no");
		ParamUtil::copyObj2Array($v_param, $this, "school_id");
		ParamUtil::copyObj2Array($v_param, $this, "title");
		ParamUtil::copyObj2Array($v_param, $this, "member_count");
		ParamUtil::copyObj2Array($v_param, $this, "manager_id");
		ParamUtil::copyObj2Array($v_param, $this, "delete_flg");

		// 保存
		parent::_save("class_mst", $v_param);
	}
}