<?php
/**
 * SchoolMst Entity
 * $Id: SchoolMst.inc,v 1.1 2020/2/27 14:40:01 Exp $
 * @author zb
 * @package jp.compass.entity
 * @access public
 */
class SchoolMst extends CompassDynamicData
{
	var $school_no;
	var $original_source;
	var $title;
	var $school_type;
	var $front_image;
	var $comment;
	var $address;
	var $province;
	var $city;
	var $district;
	var $street;
	var $longitude;
	var $latitude;
	var $delete_flg;

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

		$this->school_no       = $record["school_no"];
		$this->original_source = $record["original_source"];
		$this->title           = $record["title"];
		$this->school_type     = $record["school_type"];
		$this->front_image     = $record["front_image"];
		$this->comment         = $record["comment"];
		$this->address         = $record["address"];
		$this->province        = $record["province"];
		$this->city            = $record["city"];
		$this->district        = $record["district"];
		$this->street          = $record["street"];
		$this->longitude       = $record["longitude"];
		$this->latitude        = $record["latitude"];
		$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("SchoolMst", "school_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("school_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("SchoolMst", "school_mst", $id, $param);
	}

	// -- 这里开始Dynamic ---
	/**
	 * 将此实例写入DB。
	 * DynamicData共用的保存方法。
	 * @access public
	 * @return int 写入实例的ID
	 */
	public function save()
	{
		$v_param = array();

		ParamUtil::copyObj2Array($v_param, $this, "school_no");
		ParamUtil::copyObj2Array($v_param, $this, "original_source");
		ParamUtil::copyObj2Array($v_param, $this, "title");
		ParamUtil::copyObj2Array($v_param, $this, "school_type");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "front_image");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "comment");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "address");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "province");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "city");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "district");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "street");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "longitude");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "latitude");
		ParamUtil::copyObj2Array($v_param, $this, "delete_flg");

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