<?php
	require_once dirname(__FILE__)."/dalBase.php";
	class count_totalDAL extends dalBase{
		public $CountID;
		public $IP;
		public $Date;

		public function insertRecord(){
			$sql = "INSERT INTO `count_total` (`IP`, `Date`)" .
				" VALUES (@IP,@Date)";
			$sql = str_replace("@IP","'".$this->IP."'",$sql);
			$sql = str_replace("@Date","'".$this->Date."'",$sql);

			$this->data->executeNonQuery($sql);
			if(!$this->data->error)
				return $this->data->getInsertID();
			return false;
		}
		//查詢
		public function executeRecordset($filter="",$order="",$start=0,$length=-1){
			$sql = "SELECT a.* FROM `count_total` a";
			if(trim($filter) != "")
				$sql .= " WHERE ".$filter;
			if(!isset($order) || $order == "")
				$sql .= " ORDER BY a.`CountID`";
			else
				$sql .= " ORDER BY ".$order;
			return $this->data->executeRecordset($sql,$start,$length);
		}
		//查詢計數
		public function countRecordset($filter=""){
			$sql = "SELECT COUNT(*) FROM `count_total` a";
			if($filter != "")
				$sql .= " WHERE ".$filter;

			return $this->data->executeScalar($sql);
		}

		//刪除
		public function deleteRecord($filter=""){
			$sql = "DELETE FROM `count_total` WHERE ".$filter;
			$this->data->executeNonQuery($sql);

			if(!$this->data->error)
				return true;
			return false;
		}
	}
?>