<?php
Doo::loadCore ( 'db/DooModel' );
class notificationConf extends DooModel {
	public $nid;
	public $sid;
	public $conf;
	public $_table = 'CLD_notificationConf';
	public $_primarykey = 'nid';
	public $_fields = array (
			'nid',
			'sid',
			'conf',
			
	);
	
	/**
	 * 据用户ID获得信息配置
	 * @param number $sid
	 */
	function getNotificationConfBySid($sid = 0) {
		if (empty($sid))
			return array();
		$detail=$this->getOne(array(
				'where'=>"sid=".$sid,
				'asArray'=>TRUE
		));
		
		return $detail;
	}
	
	/**
	 * 添加一个信息配置
	 * @param array $item 相关数据
	 * @return number 返回ID
	 */
	public function addNotification($item = array()) {
		$id = 0;
		if (is_array ( $item ) && ! empty ( $item )) {
			foreach ( $item as $key => $value ) {
				$this->$key = $value;
			}
			$id = $this->insert ();
		}
		return $id;
	}
	
	/**
	 * 根据参数字段更新相应字段（主键ID必须传）
	 * @param array $item 相关需要更新的字段信息
	 * @return number 返回发票ID
	 */
	public function setNotificationByCondition($item = array()) {
		$id = 0;
		if (is_array ( $item ) && ! empty ( $item )) {
			foreach ( $item as $key => $value ) {
				$this->$key = $value;
			}
			$id = $this->update ();
		}
		return $id;
	}
	
}

?>