PHP遞迴寫入MySQL無限級分類資料

2021-07-27 19:31:04 字數 1072 閱讀 3200

php遞迴寫入mysql無限級分類資料,表結構:

create table `kepler_goods_category` (

`id` int unsigned not null primary key auto_increment,

`parentid` int unsigned not null default 0 comment '父級分類id',

`name` varchar(255) not null default '' comment '分類名稱',

`kepler_fid` int unsigned not null default 0 comment '對應克卜勒分類id',

`create_time` timestamp not null default current_timestamp on update current_timestamp

) engine=innodb default charset=utf8;

遞迴方法**:

static public function addcategoryfromkepler($fid, $parentid = 0)

} return true;

}

呼叫**:

keplercategory::addcategoryfromkepler(0);

遞迴方法讀取**:

static public function getcategoryformattokepler($parentid, $format_data = array(), $parent_prefix = '', $current_prefix = '')

}else

return $format_data;

}

呼叫**:

$category_list = keplercategory::getcategoryformattokepler(0);

PHP遞迴寫入MySQL實現無限級分類資料操作示例

php遞迴寫入mysql無限級分類資料,表結構 create table kepler goods category id int unsigned not null primary key auto increment,parentid int unsigned not null default ...

PHP 無限級分類 遞迴

arr array array id 1,name 電腦 pid 0 array id 2,name 手機 pid 0 array id 3,name 筆記本 pid 1 array id 4,name 台式電腦 pid 1 array id 5,name 智慧型機 pid 2 array id 6...

MySQL無限級分銷, PHP無限級分銷

需求 a推薦b,b推薦c c推薦d 永遠不斷,不限制推薦層級 每個人只允許有乙個上線 根據下線的人數設定規則規則,也可實現五級三晉制 資料結構為 典型的樹結構 需解決的問題 1 快速查詢某人的所有上線 2 快速查詢某人的所有下線 3 快速為某人增加乙個下線 解決方案 有四種 一 鄰接表 依賴父節點 ...