function getCateNameById($id) { $mmc = new MMCache(); $mmkey = "categoryId_list"; $list = $mmc->get($mmkey); if (empty($list)) { //从数据库里取 $mysql = new Mysql(); $sqlformat = "select Id,Name from %scategory%s where belong=%d"; $sql = sprintf($sqlformat, $mysql->dbpre, $mysql->debug, intval($this->Belong)); $data = $mysql->getData($sql); $mysql->closeDb(); if (!empty($data)) { $list = $data; $mmc->set($mmkey, $data); } } if (!empty($list)) { for ($i = 0; $i < count($list); $i++) { if ($list[$i]["Id"] == $id) { return $list[$i]["Name"]; } } } else { return "未知分类"; } }