<?php

/*
 * Copyright (C) xgcms.com
 */

class topic_subject extends base_model {
	
	function __construct(&$conf) {
		parent::__construct($conf);
		$this->table = 'topic_subject';
		$this->primarykey = array('tid');
	}
	public function _create($data){
		$subject=misc::safe_str($data['subject']);
		$arr=array('tid'=>$data['tid'],'fid'=>$data['fid'],'subject'=>$subject,'subject_md5'=>md5($subject),'dateline'=>$data['dateline']);
		$rs=$this->read($data['tid']);
		if($rs) return 0;
		return $this->create($arr);
		}
		public function _read($md5){
			$rs=$this->index_fetch(array('subject_md5'=>$md5),array(),0,1);
			return $rs?array_pop($rs):0;
		}
}