How does the PHP branch tree exclude a branch from being processed?

Source: Internet
Author: User

Hello everyone, I am a novice. Ask you a question.

A is the pyramid vertex, below has the junior member ABCdef and so on several, each junior member below also has the junior member several, this has been arranged continuously.


If the E1 membership is upgraded to a tier one member, a can receive a commission of 10 dollars.

But if his on-line is B1 status as a member, then 10 yuan will be returned to B1.

What kind of thought should be used to count the percentage of a in a certain time period, that is, the commission of all branches of a must rule out the member data in the B1 branch.

Reply content:

Hello everyone, I am a novice. Ask you a question.

A is the pyramid vertex, below has the junior member ABCdef and so on several, each junior member below also has the junior member several, this has been arranged continuously.


If the E1 membership is upgraded to a tier one member, a can receive a commission of 10 dollars.

But if his on-line is B1 status as a member, then 10 yuan will be returned to B1.

What kind of thought should be used to count the percentage of a in a certain time period, that is, the commission of all branches of a must rule out the member data in the B1 branch.

Traverse the child node of a, if not a member, add a linear table (indicating that the node is upgraded, a can gain), and then continue to traverse this node

//伪代码 获取到A节点可以获得收益的后辈节点//topNode为节点对象function getAllChilds(object topNode){    static childArr=[];    foreach(topNode->getAllChilds as index=>tempChildNode){        //如果当前节点不为一级节点        if(!tempChildNode->rankIsOne){            array_push(childArr,tempChildNode);            getAllChilds(tempChildNode);        }    }    return childArr;}

But look at the topic is a time period A of the Commission, meaning as if the node tree each node rank is going to change, this is a bit difficult
Or, each time the node is upgraded, it calculates the gain, the revenue node, and the time, written to the database. This makes the query require only one SQL statement.

Traverse all the nodes and remove the parent node from the tree as the branch of the member you requested. ......

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.