💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
~~~ > 数据表结构 DROP TABLE IF EXISTS `shop_category`; CREATE TABLE IF NOT EXISTS `shop_category`( `cateid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `title` VARCHAR(32) NOT NULL DEFAULT '', `parentid` BIGINT UNSIGNED NOT NULL DEFAULT '0', `createtime` INT UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY(`cateid`), KEY shop_category_parentid(`parentid`) )ENGINE=InnoDB DEFAULT CHARSET=utf8; ~~~ ~~~ > 按照parentid排列数组 public function getTree($cates, $pid = 0) { $tree = []; foreach($cates as $cate) { if ($cate['parentid'] == $pid) { $tree[] = $cate; $tree = array_merge($tree, $this->getTree($cates, $cate['cateid'])); } } return $tree; } ~~~ ~~~ > 按照parentid等级,接上字符串 |----- ~~~