get_child_tree() 朴灿烈づ我的快乐病毒、 2022-10-02 03:51 119阅读 0赞 [2019独角兽企业重金招聘Python工程师标准>>> ][2019_Python_] ![hot3.png][] mobile/include/lib\_goods.php function get_child_tree($tree_id = 0) { $three_arr = array(); $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '$tree_id' AND is_show = 1 "; if ($GLOBALS['db']->getOne($sql) || $tree_id == 0) { /* SELECT cat_id, cat_name, parent_id, is_show FROM ecs_category WHERE parent_id =$type_id AND is_show=1 ORDER BY sort_order ASC,cat_id ASC; */ $child_sql = 'SELECT cat_id, cat_name, parent_id, is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '$tree_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($child_sql); foreach ($res AS $row) { if ($row['is_show']) $three_arr[$row['cat_id']]['id'] = $row['cat_id']; $three_arr[$row['cat_id']]['name'] = $row['cat_name']; $three_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); if (isset($row['cat_id']) != NULL) { $three_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']); } } } return $three_arr; } 转载于:https://my.oschina.net/xuyaoxiang/blog/759352 [2019_Python_]: https://my.oschina.net/u/2663968/blog/3061697 [hot3.png]: /images/20220113/e09978e0008d47eea44fed8cbd7d0fdb.png
还没有评论,来说两句吧...