<?php
/**
 * DynamicData
 * 
 * $Id: KoalaDynamicData.inc,v 1.1 2015/10/08 11:18:57 wanggb Exp $
 * @access public
 * @package jp.fishow.entity
 */

class CompassDynamicData extends EntityBase{


	/**
	 * ID。KoalaDynamicData
	 * @var int
	 */
	public $id;
	public $registration_date;

	/**
	 * 
	 * 
	 * @access	public
	 * @param array $record DynamicData
	 */
	public function __construct($record = null) {
		if ($record != null) {
			$this->constructor($record);
		}
	}

	/**
	 * 
	 * @access private
	 * @param array $record MazaEntity
	 */
	public function constructor($record) {
		$this->id = $record["id"];
		$this->registration_date = $record["registration_date"];
	}

	/**
	 * 
	 * 
	 * @abstract
	 */
//	public function getList($w_param, $orderkey = null, $direction = "ASC", $offset = null, $limit = null) {
//		ErrorLogger::doOutput("abstract getList called!", 0);
//	}

	/**
	 * 
	 * 
	 * @abstract
	 */
	public function save() {
		ErrorLogger::doOutput("abstract save called!", 0);
	}


	public function _save($table_name, $v_param, $force = false) {
		$db = CompassDBManager::getInstance();

		if ((isset($this->id)) && (!$force)) {
			// 
			$w_param = array();
			$w_param["id"] = $this->id;
			// 

			$db->doUpdate($table_name, $w_param, $v_param);
		} else {
			// 
			if (!isset($this->registration_date)) {
				$v_param["registration_date"] = date("Y-m-d H:i:s");
			} else {
				$v_param["registration_date"] = $this->registration_date;
			}

			// insert doInsert
			//$result = $db->doInsertAndReturn($table_name, $v_param);
			$result = $db->doInsert($table_name, $v_param);

			if (is_array($result) && count($result) > 0) {
				// 
				$this->constructor($result[0]);
			}
		}
	}
	
	
}

?>