Markdown::getBlogByCategory PHP Méthode

getBlogByCategory() public méthode

按分类查找博客
public getBlogByCategory ( $categoryId )
    public function getBlogByCategory($categoryId)
    {
        $cacheKey = "getBlogByCategory_" . $categoryId . ".gb";
        $blogList = $this->gbReadCache($cacheKey);
        if ($blogList === false) {
            $blogList = array();
            foreach ($this->blogs as $idx => $blog) {
                $categoryArr = $blog['category'];
                if (count($categoryArr) > 0) {
                    foreach ($categoryArr as $idx => $cateObj) {
                        if ($cateObj['id'] == $categoryId) {
                            array_push($blogList, $blog);
                            continue;
                        }
                    }
                }
            }
            $this->gbWriteCache($cacheKey, $blogList);
        }
        return $blogList;
    }