Beispiel #1
0
 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 "未知分类";
     }
 }
Beispiel #2
0
 function getListByParentIdCache($parentId, $expire = 0)
 {
     $memcache = new MMCache();
     $mmckey = "Department_List_" . $this->ParentId;
     $list = $memcache->getValue($mmckey);
     if ($list) {
         return $list;
     } else {
         $data = $this->getListByParentId($parentId);
         if ($data["Data"]) {
             $memcache->setValue($mmckey, $data, $expire);
         }
         return $data;
     }
 }
Beispiel #3
0
 public function get($condition = null)
 {
     $result = array();
     if (is_null($condition)) {
         return $this->__storage;
     }
     if (isset($condition['category'])) {
         if (is_array($condition['category'])) {
             foreach ($condition['category'] as $cat) {
                 array_push($result, MMCache::queryAll($this->__storage, 'category', $cat));
             }
         } else {
             array_push($result, MMCache::queryAll($this->__storage, 'category', $condition['category']));
         }
     }
     if (isset($condition['status'])) {
         switch ($condition['status']) {
             case 'OK':
                 array_push($result, MMCache::queryAll($this->__storage, 'status', 'OK'));
             case 'WARNING':
                 array_push($result, MMCache::queryAll($this->__storage, 'status', 'WARNING'));
             case 'ERROR':
             default:
                 array_push($result, MMCache::queryAll($this->__storage, 'status', 'OK'));
         }
     }
     return $result;
 }
Beispiel #4
0
<?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;
Beispiel #5
0
function getChildCategoryId($blogid, $id)
{
    $context = Model_Context::getInstance();
    if ($context->getProperty('category.raw') === null) {
        getCategories($blogid, 'raw');
    }
    //To cache category information.
    if ($result = MMCache::queryColumn($context->getProperty('category.raw'), 'parent', $id, 'id')) {
        return $result;
    }
    return null;
}
Beispiel #6
0
function getChildCategoryId($blogid, $id)
{
    global $__gCacheCategoryRaw;
    if (empty($__gCacheCategoryRaw)) {
        getCategories($blogid, 'raw');
    }
    //To cache category information.
    if ($result = MMCache::queryColumn($__gCacheCategoryRaw, 'parent', $id, 'id')) {
        return $result;
    }
    return null;
}