<?php

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

class topic_pic extends base_model {
	
	function __construct(&$conf) {
		parent::__construct($conf);
		$this->table = 'topic_pic';
		$this->primarykey = array('fid','tid');
		
		// hook topic_pic_construct_end.php
	}
	public function get_list_by_fid($fid,$start=0,$pagesize=20){
		$cond=array('fid'=>$fid);
		//hook model_topic_pic_get_list_by_fid_start.php
		$list=$this->index_fetch($cond,array('tid'=>-1),$start,$pagesize);
		$tids=array();
		foreach($list as $v){
			$tids[]=array($v['fid'],$v['tid']);
		}
		//$tids=array_unique($tids);
		return $list=$this->topic->mget($tids);
		
	}
	public function get_list($num=8){
		$list=$this->index_fetch(array(),array('tid'=>-1),0,$num);
		$tids=array();
		foreach($list as $v){
			$tids[]=array($v['fid'],$v['tid']);
		}
		$list=$this->topic->mget($tids);
		foreach($list as &$t){
			$this->topic->format($t);
		}
		return $list;
	}
	
}