public function testGetRootEqualsValueIfSetIfUnpersisted() { $parent = Category::roots()->first(); $child = new Category(); $child->setAttribute($child->getParentColumnName(), $parent->getKey()); $this->assertEquals($child->getRoot(), $parent); }
public function getRootCategory() { return Category::getRoot(); }
/** * ham get thong tin category * @param type $lang */ public static function getListCategory($lang = 'vi') { $root = Category::getRoot(); return Yii::app()->db->createCommand()->select('c.id, c_l.name, created_by, modified_by, description, hits, parent_id, level, lft, rgt')->from('category c')->join('category_language c_l', 'c.id = c_l.category_id')->join('language lang', 'lang.id = c_l.language_id')->where('lang.code =:code', array(':code' => $lang))->andWhere('lft BETWEEN :lft AND :rgt', array(':lft' => $root['lft'], ':rgt' => $root['rgt']))->andWhere('parent_id <> 0 AND level <> 0')->order('lft asc')->queryAll(); }