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 "未知分类"; } }
<?php /*phpinfo(); return;*/ require __DIR__ . '/autoload.php'; $kv = new KVDB(); $kv->set("name", "sauwe"); $kv->delete("name"); echo $kv->get("name"); return; $mmcache = new MMCache(); //$mmcache->delete("key"); //$mmcache->set("key","问少尉",600); echo $mmcache->get("key"); return; $imgurl = 'http://localhost:86/temporary/test.jpg'; $request = new HttpRequest(false, false); $img_data = $request->get($imgurl); $img = new Image(); $img->setData($img_data); //$img->resize(300); // 等比缩放到200宽 $img->annotate("翁少尉1", 0.5, GRAVITY_SOUTHEAST, array("name" => FONT_MicroHei, "size" => 100, "color" => "red")); $new_data = $img->exec(); // 执行处理并返回处理后的二进制数据 $ftype = "jpg"; $stor = new Storage(); $picurlm = $stor->write(FILE_DIR_TEMP, "_400." . $ftype, $new_data); return; $stor = new Storage(); $picurl = $stor->upload(FILE_DIR_TEMP, $destination, $filename); return;