Php 有人知道如何在sql中创建二叉树吗
我正在创建传销网站,现在我想建立二叉树。。 这样用户就可以输入他们的私人id并选择赞助商id 二叉树的工作原理如下:Php 有人知道如何在sql中创建二叉树吗,php,sql,Php,Sql,我正在创建传销网站,现在我想建立二叉树。。 这样用户就可以输入他们的私人id并选择赞助商id 二叉树的工作原理如下: 1 is root 2 is child of 1 3 is child of 1 Then 4 is child of 2 5 is child of 2 6 is child of 3 7 is child of 3 谢谢。在每一行中维护左子女,右子女,以及赞助商id(会员记录) 但是在注册之后。。这个值如何自动递增。。。left_child或right_child如果
1 is root
2 is child of 1
3 is child of 1
Then 4 is child of 2
5 is child of 2
6 is child of 3
7 is child of 3
谢谢。在每一行中维护
左子女
,右子女
,以及赞助商id
(会员记录)
但是在注册之后。。这个值如何自动递增。。。left_child或right_child如果插入新成员,则此选项将为空或0。在传销中,您知道,新成员只需要注册赞助商id。我很自豪自己是印度人。。。你能告诉我整个过程吗。。mysql中应该有多少列可用,使用php如何插入…新成员包含leg:right或left。。赞助商id和新用户id
| ID | Name | left_child | right_child | sponser_id |
|:-----------|------------:|:-----------:|:------------:|:----------:|
| 1 | Root | 2 | 2 | |
| 2 | child-2 | 4 | 5 | 1 |
| 3 | child-3 | 6 | 7 | 1 |
| 4 | child-4 | x | y | 2 |
| 5 | child-5 | a | b | 2 |