<?php
/**
 * TeacherMst Entity
 * $Id: TeacherMst.inc,v 1.1 2020/1/15 11:01:52 Exp $
 * @author lixq
 * @package jp.compass.entity
 * @access public
 */
class TeacherMst extends CompassDynamicData
{
	var $school_id;
	var $grade_id;
	var $class_id;
	var $name;
	var $contact;
	var $qq_no;
	var $area;
	var $sex;
	var $channel_no;
	var $status;
	var $uid;
	var $account_id;
	var $point;
	var $zfb_account;
	var $delete_flg;

	/**
	 * 构造实现。teacher_mst创建实例。
	 * 
	 * @access public
	 * @param mixed teacher_mst
	 */
	function constructor($record)
	{
		parent::constructor($record);

		$this->school_id   = $record["school_id"];
		$this->grade_id    = $record["grade_id"];
		$this->class_id    = $record["class_id"];
		$this->name        = $record["name"];
		$this->contact     = $record["contact"];
		$this->qq_no       = $record["qq_no"];
		$this->area        = $record["area"];
		$this->sex         = $record["sex"];
		$this->channel_no  = $record["channel_no"];
		$this->status      = $record["status"];
		$this->uid         = $record["uid"];
		$this->account_id  = $record["account_id"];
		$this->point       = $record["point"];
		$this->zfb_account = $record["zfb_account"];
		$this->delete_flg  = $record["delete_flg"];
	}

	/**
	 * 根据条件,获取数据列表。
	 * 条件与DBManager的doSelect相同。
	 * @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("TeacherMst", "teacher_mst", $w_param, $orderkey, $direction, $offset, $limit);
	}

	/**
	 * 根据条件，获取数据列表的件数。
	 * 条件与DBManager的doSelect相同。
	 * @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("teacher_mst", $w_param, null, null, null, null, "count(*) as count");

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

	/**
	 * 获得此类指定ID的实例。
	 */
	public static function getById($id)
	{
		// delete_flg
		$param = array();
		$param["delete_flg"] = false;

		return CompassDBHandler::getById("TeacherMst", "teacher_mst", $id, $param);
	}

	// -- 这里开始Dynamic ---
	/**
	 * 将此实例写入DB。
	 * DynamicData共用的保存方法。
	 * @access public
	 * @return int 写入实例的ID
	 */
	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_id");
		ParamUtil::copyObj2Array($v_param, $this, "name");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "contact");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "qq_no");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "area");
		ParamUtil::copyObj2Array($v_param, $this, "sex");
		ParamUtil::copyObj2Array($v_param, $this, "channel_no");
		ParamUtil::copyObj2Array($v_param, $this, "status");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "uid");
		ParamUtil::copyObj2Array($v_param, $this, "account_id");
		ParamUtil::copyObj2Array($v_param, $this, "point");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "zfb_account");
		ParamUtil::copyObj2Array($v_param, $this, "delete_flg");

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