根据父级ID查询出全部子级
PHP Code复制内容到剪贴板
- private static function recursion($res)
- {
- $output = array();
- foreach ($res as $k => $v)
- {
- $sql = "select * from broad_category WHERE pid=".$v['id'];
- $tmpRes = Yii::$app->db->createCommand($sql)->queryAll();
- $output []= $v;
- if (!emptyempty($tmpRes))
- {
- $output = array_merge($output, self::recursion($tmpRes));
- }
- }
- return $output;
- }