Get all the subclass methods below the taxonomy:
static function Getmenutree ($arrCat, $parent _id = 0, $level = 0, $all =true) { static $arrTree;//Use static instead of global if (! $all) $arrTree = '; if (empty ($arrCat)) return FALSE; $level + +; if ($level = = 1) $arrTree [] = $parent _id; foreach ($arrCat as $key = + $value) { if ($value [' parent_cid '] = = $parent _id) { //$value [' level '] = $ level; $arrTree [] = $value [' CID ']; Unset ($arrCat [$key]); Unregisters the current node data, reducing the useless traversal self::getmenutree ($arrCat, $value [' CID '], $level); } } return $arrTree; }
The premise of using this method is to write the classification to the cache file, the cache file is written as follows:
Public Function ActionIndex2 () {$filepath = Yii::getpathofalias (' application '). ' /data/'; $arr = Array (); $db = Yii::app ()->db; $listinfo = $db->createcommand ("Select Name,cid,parent_cid,root_cid from Item_cat_info")->queryall (); foreach ($listinfo as $val) { $arr [$val [' cid ']] = Array (' cid ' + = $val [' CID '], ' name ' = + $val [' name '], ' Parent_ CID ' = $val [' parent_cid '], ' root_cid ' and ' = ' $val [' root_cid ']); } $applist = "<?php\nreturn". Var_export ($arr, true). "; N?> "; File_put_contents ($filepath. ' itemcat.php ', $applist); }
http://www.bkjia.com/PHPjc/825424.html www.bkjia.com true http://www.bkjia.com/PHPjc/825424.html techarticle get all subclass methods under classification: static function Getmenutree ($arrCat, $parent _id = 0, $level = 0, $all =true) {static $arrTree;//Use Stati c instead of global if (! $all) $arrTr ...