public static function getOrCreate($categoryName) { $categoryDAO = new Category(); $category = $categoryDAO->findFirst("categoryName='{$categoryName}'"); $pinyin = new Pinyin(); if (!$category) { $category = new Category(); $category->categoryName = $categoryName; $category->initial = substr($pinyin->transformUcwords($category->categoryName), 0, 1); $category->save(); } return $category; }