當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRUD::findById方法代碼示例

本文整理匯總了PHP中CRUD::findById方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRUD::findById方法的具體用法?PHP CRUD::findById怎麽用?PHP CRUD::findById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRUD的用法示例。


在下文中一共展示了CRUD::findById方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doMobileIndex

 public function doMobileIndex()
 {
     global $_GPC, $_W;
     $fid = $_GPC['fid'];
     $fool = CRUD::findById(CRUD::$table_fool, $fid);
     include $this->template("index");
 }
開發者ID:keycoolkui,項目名稱:weixinfenxiao,代碼行數:7,代碼來源:site.php

示例2: doMobileSign

 /**
 * 
 * 簽到
 * 類型 1:關注積分 2:每日積分 3:連續積分
 */
 public function doMobileSign()
 {
     global $_GPC;
     $sid = $_GPC['sid'];
     $res = array();
     $sign = CRUD::findById(CRUD::$table_sign, $sid);
     if (empty($sign)) {
         $res['code'] = 501;
         $res['msg'] = "積分簽到活動已刪除或不存在!";
         echo json_encode($res);
         exit;
     }
     $clientUser = $this->getClientUserInfo();
     if (empty($clientUser)) {
         $res['code'] = 501;
         $res['msg'] = "請關注公眾賬號再進行簽到";
         echo json_encode($res);
         exit;
     }
     $signUser = $this->findSignUser($clientUser['openid'], $sid);
     if (!empty($signUser) && $this->findTodayUserSign($sid, $signUser['id']) > 0) {
         //今天已經簽過到了
         $res['code'] = 503;
         $res['msg'] = "您今天已經簽過到了,明天再來吧!";
         echo json_encode($res);
         exit;
     }
     if (empty($signUser)) {
         //從來沒有簽過到用戶處理
         $now = TIMESTAMP;
         $serial = $this->findUserCurrentSerial(null, $sid);
         $user_data = array("sid" => $sid, "begin_sign_time" => $now, "end_sign_time" => $now, "openid" => $clientUser['openid'], "nickname" => $clientUser['nickname'], "headimgurl" => $clientUser['headimgurl'], "serial_id" => $serial['id'], "credit" => $sign['sign_credit'], "sin_count" => 1);
         CRUD::create(CRUD::$table_sign_user, $user_data);
         $userid = pdo_insertid();
         $record_data = array('uid' => $userid, 'openid' => $clientUser['openid'], 'sid' => $sid, 'sin_time' => $now);
         CRUD::create(CRUD::$table_sign_record, $record_data);
         //插入記錄
         $sign_award_day = array('sid' => $sid, 'uid' => $userid, 'sign_type' => 2, 'credit' => $sign['sign_credit'], 'createtime' => TIMESTAMP);
         CRUD::create(CRUD::$table_sign_award, $sign_award_day);
         // 插入積分記錄
         $res['code'] = 200;
         $res['msg'] = "恭喜您獲得日簽到積分" . $sign['sign_credit'] . "分!";
         if ($sign['sync_credit'] == 1) {
             //同步積分
             $this->synFanscredit($clientUser['openid'], $sign['sign_credit']);
         }
         echo json_encode($res);
         exit;
     }
     //已經簽到過用戶 簽到
     if (!empty($signUser)) {
         $sin_time = TIMESTAMP;
         $user_credit = $signUser['credit'];
         $user_sin_count = $signUser['sin_count'];
         $user_sin_serial = $signUser['sin_serial'];
         $day_record_data = array('uid' => $signUser['id'], 'openid' => $clientUser['openid'], 'sid' => $sid, 'sin_time' => $sin_time);
         CRUD::create(CRUD::$table_sign_record, $day_record_data);
         CRUD::updateById(CRUD::$table_sign_user, array("end_sign_time" => $sin_time), $signUser['id']);
         //更新最終的簽到時間
         $sign_award_day = array('sid' => $sid, 'uid' => $signUser['id'], 'sign_type' => 2, 'credit' => $sign['sign_credit'], 'createtime' => TIMESTAMP);
         CRUD::create(CRUD::$table_sign_award, $sign_award_day);
         // 插入日積分得獎表
         $user_credit = $user_credit + $sign['sign_credit'];
         $user_sin_count = $user_sin_count + 1;
         $user_serial_days = $signUser['sin_serial'];
         $serial = $this->findUserCurrentSerial($signUser, $sid);
         $serial_id = $serial['id'];
         $mserial_credit = 0;
         $serial_day = $serial['day'];
         $begintime = date('Y-m-d' . '00:00:00', $signUser['begin_sign_time']);
         $endtime = date('Y-m-d' . '23:59:59', $sin_time);
         $beginSinTimeStamp = strtotime($begintime);
         $endSinTimeStamp = strtotime($endtime);
         $offsertDays = $this->getOffsetdays($beginSinTimeStamp, $endSinTimeStamp);
         $recordOffsetDays = $this->findUserSerialRecordCount($beginSinTimeStamp, $endSinTimeStamp, $sid, $signUser['id']);
         //查詢記錄簽到的連續時間
         if ($recordOffsetDays < $offsertDays) {
             // 簽到時間斷了,重新計算
             $this->updateUserSinTime($sin_time, $sin_time, $signUser['id']);
             //重置遊標
         } else {
             if ($recordOffsetDays == $recordOffsetDays && $recordOffsetDays == $serial_day) {
                 //達到了連續簽到
                 $sign_award_serial = array('sid' => $sid, 'uid' => $signUser['id'], 'sign_type' => 3, 'credit' => $serial['credit'], 'serial_start_time' => $signUser['begin_sign_time'], 'serial_end_time' => $sin_time, 'serial_day' => $serial_day, 'createtime' => TIMESTAMP);
                 CRUD::create(CRUD::$table_sign_award, $sign_award_serial);
                 //  插入連續積分
                 //更新award 表
                 $user_credit = $user_credit + $serial['credit'];
                 $serial_id = $this->findNextSerialId($serial['day'], $sid);
                 //查找下一次 連續 ID 計算
                 $user_serial_days = $user_serial_days + $serial_day;
                 $mserial_credit = $serial['credit'];
             }
         }
         $m_sin_user_data = array("serial_id" => $serial_id, "credit" => $user_credit, 'sin_count' => $user_sin_count, 'sin_serial' => $user_serial_days);
//.........這裏部分代碼省略.........
開發者ID:ChainBoy,項目名稱:wxfx,代碼行數:101,代碼來源:site.php


注:本文中的CRUD::findById方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。