NewsDat.inc 3.1 KB
<?php
/**
 * NewsDat Entity
 * $Id: NewsDat.inc,v 1.1 2020/2/27 14:40:01 Exp $
 * @author zb
 * @package jp.compass.entity
 * @access public
 */
class NewsDat extends CompassDynamicData
{
	var $title;
	var $content;
	var $front_image_big;
	var $front_image_small;
	var $read_count;
	var $account_title;
	var $account_id;
	var $level_id;
	var $is_top;
	var $delete_flg;

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

		$this->title        		= $record["title"];
		$this->content 				= $record["content"];
		$this->front_image_big   	= $record["front_image_big"];
		$this->front_image_small  	= $record["front_image_small"];
		$this->read_count  			= $record["read_count"];
		$this->account_title  		= $record["account_title"];
		$this->account_id  			= $record["account_id"];
		$this->level_id    			= $record["level_id"];
		$this->is_top    			= $record["is_top"];
		$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("NewsDat", "news_dat", $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("news_dat", $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("NewsDat", "news_dat", $id, $param);
	}

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

		ParamUtil::copyObj2Array($v_param, $this, "title");
		ParamUtil::copyObj2Array($v_param, $this, "content");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "front_image_big");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "front_image_small");
		ParamUtil::copyObj2Array($v_param, $this, "read_count");
		ParamUtil::copyObj2Array($v_param, $this, "account_title");
		ParamUtil::copyObj2Array($v_param, $this, "account_id");
		ParamUtil::copyObj2Array($v_param, $this, "level_id");
		ParamUtil::copyObj2Array($v_param, $this, "is_top");
		ParamUtil::copyObj2Array($v_param, $this, "delete_flg");

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