本文整理汇总了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");
}
示例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);
//.........这里部分代码省略.........