Exemplo n.º 1
0
 public static function pyramid($m_id = NULL)
 {
     $custom = is_null($m_id) ? "referrals IS NULL" : "id = '{$m_id}'";
     $rsnum = CRUD::dataFetch('member', array("custom" => $custom, 'status' => '1', 'verify' => '1'));
     if (!empty($rsnum)) {
         # 金字塔起頭 (多組或單組)
         $pyramid = CRUD::$data;
         foreach ($pyramid as $key => $row) {
             self::$data = array();
             # 清空紀錄
             # 取得上層 id
             if (!is_null($row["referrals"])) {
                 $referrals_num = CRUD::dataFetch('member', array("account" => $row["referrals"], 'status' => '1', 'verify' => '1'));
                 if (!empty($referrals_num)) {
                     $referrals = CRUD::$data[0]["id"];
                 }
             } else {
                 $referrals = 0;
             }
             self::$data[0][$referrals] = $row;
             self::pyramid_level($row);
             self::$group[$key] = self::$data;
         }
         return true;
     } else {
         # 查無資料
         return false;
     }
 }