<?php

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

class type extends base_model {
	function __construct(&$conf) {
		parent::__construct($conf);
		$this->table = 'type';
		$this->primarykey = array('typeid');
		$this->maxcol = 'typeid';
	}
	public function get_list(){
		$catelist = $this->index_fetch(array('pid'=>0), array('rank'=>-1), 0, 1000);
		foreach($catelist as &$cate) {
			$cate['catelist_son'] = $this->index_fetch(array('pid'=>$cate['typeid']), array('rank'=>1), 0, 1000);
		}
		return $catelist;
	}
	public function get_typearr($pid=0){
		$catelist = $this->index_fetch(array('pid'=>$pid), array('rank'=>-1), 0, 1000);
		$arr=array();
		foreach($catelist as $cate) {
			$arr[$cate['typeid']] = $cate['name'];
		}
		return $arr;
	}
	public function get_name($id){
		$r=$this->read($id);
		return $r?$r['name']:'';
	}
}
?>