Phpfor
I am a novice php, recently developed projects to find a binary tree system of Welfare award. The execution efficiency is too low after the completion of writing. Ask Master big God to point out the idea.
1. The performance of about 1W is the supervisor. Under the management system, there are 2 supervisors who are managers. Under the management system, there are 2 managers who are directors. 0 Members, 1 supervisors, 2 managers, 3 directors.
I wrote the following code:
Welfare Award begins
Unset ($MAP);//Destroy the map variable value
$map [' _string ']= ' DateDiff (Curday, ' ". $beginday.") <=0 ";
Check all member Performance
$hyyjlist = $hyyj->where ($map)->field (' Userid,sum (leftyj1) +sum (leftyj2) as Sumleft ')->group (' userid ')- >select ();
$glrCountArry =array ();//key: Executive Name+flrjl Value: An array of the number of persons holding the charge
foreach ($hyyjlist as $hkey + $hvalue) {//Cycle update user's supervisor benefits
if ($hvalue [' Sumleft ']>=10000) {
$US = $userListArry [$hvalue [' UserID ']];//3 membership based on ID
if ($US [' flstate ']==0) {//status is 0 members
if ($salary 1->where (' periods ' + $periods, ' userid ' = + $US [' ID ']))->setfield (' flj ' = ' Z Supervisor Award Content Z ')) (===false) {
$salary->rollback ();
$this->error (' Welfare Award update failed ');
}
For (!empty ($US [' gluser ']), $i =0, $i if (!array_key_exists ($US [' Gluser ']. " Flrzg ", $glrCountArry)) {
$glrCountArry [$US [' Gluser ']. " Flrzg "]=1;
}else{
$glrCountArry [$US [' Gluser ']. " Flrzg "]+=1;
}
$US = $userNameListArry [$US [' Gluser '];
if (empty ($US)) {
$i =count ($userlist);
}
}
}
}
}
$find [' State ']=array (' eq ', 1);//Status =1 active
$find [' _string ']= "From_unixtime (confirmtime, '%y-%m-%d ') $list 2= $users->where ($find)->select ();//Query member list
$glrCountArry 2=array ();//Key: Manager NAME+FLRJL Value: Number of people to save an array of managers
foreach ($list 2 as $key = + $value) {//Get Manager benefits
$US = $value;
if ($US [' flstate ']==1) {
For (!empty ($US [' gluser ']), $i =0, $i if ($glrCountArry [$US [' username ']. " Flrzg "]>0" {//Member is the executive level, the number of executives in the array is greater than 0 update member's manager benefits
if ($salary 1->where (' periods ' + $periods, ' userid ' = + $US [' ID ']))->setfield (' flj ' = ' Z Manager Prize content z ')) ===false) {
$salary->rollback ();
$this->error (' Welfare Award update failed 2 ');
}
}
if (!array_key_exists ($US [' Gluser ']. " Flrjl ", $glrCountArry 2)) {//Make the member's top manager +1
$glrCountArry 2[$US [' Gluser ']. " Flrjl "]=1;
}else{
$glrCountArry 2[$US [' Gluser ']. " Flrjl "]+=1;
}
$US = $userNameListArry [$US [' Gluser '];
if (empty ($US)) {
$i =count ($userlist);
}
}
}else if ($value [' flstate ']==0) {//Membership level is not supervisor, number of supervisors is greater than 1 update member's manager benefits
For (!empty ($US [' gluser ']), $i =0, $i if ($glrCountArry [$US [' username ']. " Flrzg "]>1" {//Member is the executive level, the number of executives in the array is greater than 0 update member's manager benefits
if ($salary 1->where (' periods ' + $periods, ' userid ' = + $US [' ID ']))->setfield (' flj ' = ' Z Manager Prize content z ')) ===false) {
$salary->rollback ();
$this->error (' Welfare Award update failed 2 ');
}
}
if (!array_key_exists ($US [' Gluser ']. " Flrjl ", $glrCountArry 2)) {//Make the member's top manager +1
$glrCountArry 2[$US [' Gluser ']. " Flrjl "]=1;
}else{
$glrCountArry 2[$US [' Gluser ']. " Flrjl "]+=1;
}
$US = $userNameListArry [$US [' Gluser '];
if (empty ($US)) {
$i =count ($userlist);
}
}
}} foreach ($list 2 as $key + $value) {//Get director's Benefits $US = $value; if ($US [' flstate ']==2) {//Status is 2 manager for (!empty ($US [' gluser ']), $i =0; $i
0) {//membership is Manager level, the number of managers array is greater than 0 update member's Director benefit if ($salary 1->where (' periods ' + $periods, ' userid ' = + $US [ ' ID '))->setfield (Array (' flj ' = ' Z ' director award Content Z ')) ===false) {$salary->rollback (); $this->error (' Welfare Award update failed 3 '); }} $US = $userNameListArry [$US [' Gluser ']; if (empty ($US)) {$i =count ($userlist); }}}else if ($value [' flstate ']<2) {//status is not manager, as long as the number of managers array reaches 2 Update members of the director benefit for (!empty ($US [' Gluser ' ]), $i =0; $i
1) {//Membership is Manager level, number of managers array is greater than 1 update member's Director benefit if ($salary 1->where (' periods ' + $periods, ' userid ' = ' + $US [' ID '])->setfield (Array (' flj ' + ' Z ' director award Content Z ')) ===false) {$salary->rollback (); $this->error (' Welfare Award update failed 3 '); }} $US = $userNameListArry [$US [' Gluser ']; if (empty ($US)) {$i =count ($userlist); }}}//Welfare award ends