Database Hierarchical Structure problem
Posted: Fri Jun 06, 2008 5:59 pm
Hello,
Sorry for my bad English.
I need some help from you on Database Hierarchical Structure, if you have heard about it, or have done any development with it before.
This how the story goes
First, I need a clear understanding of how Database Hierarchical Structure with PHP/MySql.
But before a learn it I have some urgency need of it, I used a class from phpclasses.org that works, but it remain to do something.
The Application is a network marketing application where you have someone bring somebody and somebody bring another person
Something like
Joseph has three children
Those three children (from Joseph) also has three children or even more each
Then, the last three three children also has another three three,
Just like the way files and folder are arranged in our OS (operating system)
So the class I got from phpclasses.org work out the generation tree, but what remain is
Joseph as a parent always get 1% (one percent) of each payment made by his children (Note: not grand children) then again, he(Joseph) get 2% of each payment made by his grand children which are in level 2. (Note: Joseph is in level 0, the children after Joseph are in level 1, then after the children again we have level 2, so always the level is +1, that apply to all parents)
Calculating the percentage from the array returned by the users object is just the problem.
This the structure of the generation tree table
This the structure of the member table
(I referenced the id from the generation tree table as the member section id)
The returned array is as
Please the array continue just like that,
Parent take profit at some level
Please if there is anything you can do, i need your advice.
Thank you.
Joe
Sorry for my bad English.
I need some help from you on Database Hierarchical Structure, if you have heard about it, or have done any development with it before.
This how the story goes
First, I need a clear understanding of how Database Hierarchical Structure with PHP/MySql.
But before a learn it I have some urgency need of it, I used a class from phpclasses.org that works, but it remain to do something.
The Application is a network marketing application where you have someone bring somebody and somebody bring another person
Something like
Joseph has three children
Those three children (from Joseph) also has three children or even more each
Then, the last three three children also has another three three,
Just like the way files and folder are arranged in our OS (operating system)
So the class I got from phpclasses.org work out the generation tree, but what remain is
Joseph as a parent always get 1% (one percent) of each payment made by his children (Note: not grand children) then again, he(Joseph) get 2% of each payment made by his grand children which are in level 2. (Note: Joseph is in level 0, the children after Joseph are in level 1, then after the children again we have level 2, so always the level is +1, that apply to all parents)
Calculating the percentage from the array returned by the users object is just the problem.
This the structure of the generation tree table
Code: Select all
CREATE TABLE `member_sections` (
`section_id` bigint(20) NOT NULL default '0',
`section_left` bigint(20) NOT NULL default '0',
`section_right` bigint(20) NOT NULL default '0',
`section_level` int(11) default NULL,
`section_name` varchar(255) NOT NULL default '',
PRIMARY KEY (`section_id`),
UNIQUE KEY `section_id` (`section_id`)
) TYPE=MyISAM;(I referenced the id from the generation tree table as the member section id)
Code: Select all
CREATE TABLE `club_profile` (
`cID` int(11) NOT NULL auto_increment,
`csectionID` int(11) NOT NULL default '0',
`cPWD` varchar(65) NOT NULL default '',
`cmentorID` varchar(16) NOT NULL default '',
`careaCode` varchar(16) NOT NULL default '',
`cname` varchar(150) default NULL,
`cpastPresident` varchar(15) NOT NULL default '',
`cpresident` varchar(15) NOT NULL default '',
`cvpEducation` varchar(15) NOT NULL default '',
`cvpMarketing` varchar(15) NOT NULL default '',
`cvpMemberShip` varchar(15) NOT NULL default '',
`csecretary` varchar(15) NOT NULL default '',
`ctresurer` varchar(15) NOT NULL default '',
`cvpPublicsity` varchar(15) NOT NULL default '',
`cvpInvestiment` varchar(15) NOT NULL default '',
`cvpProperty` varchar(15) NOT NULL default '',
`ceagentATARM` varchar(15) NOT NULL default '',
`cstate` varchar(25) NOT NULL default '',
`cdistric` varchar(30) NOT NULL default '',
`cactive` enum('Y','N') NOT NULL default 'N',
`csuspened` enum('Y','N') NOT NULL default 'Y',
`cdateCreated` datetime default NULL,
PRIMARY KEY (`cID`)
) TYPE=MyISAM AUTO_INCREMENT=22 ;Code: Select all
$people = array(array("name"=> "Joseph", "level" => 0,
array("name" => "Mikel", "level" => 1,
array("name" => "John", "level" => 1,
array("name" => "Oko", "level" => 2,
array("name" => "James", "level" => 1,
);Parent take profit at some level
Please if there is anything you can do, i need your advice.
Thank you.
Joe