Common time method Public function Invitationtime ($type, $v) {if ($type ==1) {//Today $beginToday = Mktime (0,0,0,date (' m '), date (' d '), Date (' Y ')); $endToday = Mktime (0,0,0,date (' m '), date (' d ') +1,date (' Y '))-1; $where = "Superior REGEXP ' ^{$v [' id ']}_ ' and createtime between '. $beginToday." and ". $endToday.";} if ($type ==2) {//Yesterday $beginYesterday = Mktime (0,0,0,date (' m '), date (' d ') -1,date (' Y ')); $endYesterday = Mktime (0,0,0,date (' m '), date (' d '), date (' Y '))-1; $where = "Superior REGEXP ' ^{$v [' id ']}_ ' and createtime between '. $beginYesterday." and ". $endYesterday.";} if ($type ==3) {//this week $beginWeek =mktime (0,0,0,date (' m '), date (' d ')-date (' W ') +1,date (' Y ')), $endWeek =mktime (23,59,59, Date (' m '), date (' d ')-date (' W ') +7,date (' Y ')); $where = "Superior REGEXP ' ^{$v [' id ']}_ ' and createtime between '. $beginWeek." and ". $endWeek.";} if ($type ==4) {//Last week $beginLastweek =mktime (0,0,0,date (' m '), date (' d ')-date (' W ') +1-7,date (' Y ')); $endLastweek =mktime ( 23,59,59,date (' m '), date (' d ')-date (' W ') +7-7,date (' Y ')); $where = "Superior REGEXP"^{$v [' id ']}_ ' and createtime between '. $beginLastweek. " and ". $endLastweek.";} if ($type ==5) {//this month $beginThismonth =mktime (0,0,0,date (' m '), 1,date (' Y ')), $endThismonth =mktime (23,59,59,date (' m '), Date (' t '), date (' Y ')); $where = "Superior REGEXP ' ^{$v [' id ']}_ ' and createtime between '. $beginThismonth." and ". $endThismonth.";} if ($type ==6) {//Last month $beginLastmonth =strtotime (' y-m-01 00:00:00 ', Strtotime ('-1 month ')); $endLastmonth = Strtotime (Date ("Y-m-d 23:59:59", Strtotime (-date (' d '). Day ')); $where = "Superior REGEXP ' ^{$v [' id ']}_ ' and createtime between '. $beginLastmonth." and ". $endLastmonth.";} return $where;} Public Function invitation ($appId, $type) {$arr = db ("indicated")->field ("Id,superior,avatar,nickname")->where (' Superior=0 ')->select (); foreach ($arr as $k + $v) {$where = Self::invitationtime ($type, $v); $arr [$k] [' count '] = db ("indicates")->where ($where)-& Gt;count (); } foreach ($arr as $key = + $val) {if ($val [' count ']==0) {unset ($arr [$key]);} else{if ($val [' Avatar ']) {$arr [$key][' Avatar ' = Cdnurl ($val [' Avatar '],true); } $sort [] = $val [' count ']; }} if (!empty ($arr)) {//Sort Array_multisort ($sort, Sort_desc, $arr); $list = Array_slice ($arr, 0,10);} return $list;}
Sort the PHP array and take the number of array bars