<?php
Doo::loadCore ( 'db/DooModel' );
class enclosur extends DooModel {
	public $eid;
	public $name;
	public $rid;
	public $_table = 'cld_enclosur';
	public $_primarykey = 'eid';
	public $_fields = array (
			'eid',
			'name',
			'rid' 
	);
	
	/**
	 * 根据报销单ID获得所有附件
	 * @param number $rid
	 * @return unknown
	 */
	function getEnclosurByRid($rid = 0) {
		if (empty ( $rid ))
			return array ();
		Doo::loadClass ( 'XDeode' );
		$XDeode = new XDeode ( 7 );
		$list = $this->find ( array (
				'where' => 'rid=' . $rid,
				'asArray' => TRUE 
		) );
		foreach ( $list as $key => $value ) {
			$list [$key] ['eidKey'] = $XDeode->encode ( $value ['eid'] );
		}
		return $list;
	}
	/**
	 * 
	 * @param number $eid
	 */
	function delEnclosurByEid($eid = 0) {
		if (empty ( $eid ))
			return 0;
		Doo::loadClass ( 'XDeode' );
		$XDeode = new XDeode ( 7 );
		$eid = $XDeode->decode ( $eid );
		$id=$this->delete ( array (
				'where' => 'eid=' . $eid
		) );
		return $id;
	}
}

?>