当前位置: 首页>>代码示例>>PHP>>正文


PHP CRUD::create方法代码示例

本文整理汇总了PHP中CRUD::create方法的典型用法代码示例。如果您正苦于以下问题:PHP CRUD::create方法的具体用法?PHP CRUD::create怎么用?PHP CRUD::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRUD的用法示例。


在下文中一共展示了CRUD::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fieldsFormSubmit

 public function fieldsFormSubmit($rid)
 {
     global $_GPC, $_W;
     $fid = $_GPC['fid'];
     $data = array('title' => $_GPC['title'], 'rid' => $rid, 'follow_url' => $_GPC['follow_url'], 'weid' => $this->weid, 'new_icon' => $_GPC['new_icon'], 'new_title' => $_GPC['new_title'], 'new_content' => $_GPC['new_content'], 'share_icon' => $_GPC['share_icon'], 'share_title' => $_GPC['share_title'], 'share_content' => $_GPC['share_content'], 'createtime' => TIMESTAMP);
     if (empty($fid)) {
         CRUD::create(CRUD::$table_fool, $data);
     } else {
         CRUD::updateById(CRUD::$table_fool, $data, $fid);
     }
     return true;
 }
开发者ID:aspnmy,项目名称:weizan,代码行数:12,代码来源:module.php

示例2: fieldsFormSubmit

 public function fieldsFormSubmit($rid)
 {
     global $_GPC, $_W;
     $sid = $_GPC['sin_id'];
     $data = array('title' => $_GPC['title'], 'rid' => $rid, 'starttime' => strtotime($_GPC['starttime']), 'endtime' => strtotime($_GPC['endtime']), 'follow_credit_allow' => $_GPC['follow_credit_allow'], 'follow_credit' => $_GPC['follow_credit'], 'leave_credit_clear' => $_GPC['leave_credit_clear'], 'sign_credit' => $_GPC['sign_credit'], 'sync_credit' => $_GPC['sync_credit'], 'sin_suc_msg' => $_GPC['sin_suc_msg'], 'sin_suc_fail' => $_GPC['sin_suc_fail'], 'sin_suc_member' => $_GPC['sin_suc_member'], 'rule' => htmlspecialchars_decode($_GPC['rule']), 'uniacid' => $this->uniacid, 'copyright' => $_GPC['copyright'], 'new_icon' => $_GPC['new_icon'], 'new_title' => $_GPC['new_title'], 'new_content' => $_GPC['new_content'], 'createtime' => TIMESTAMP);
     if (empty($sid)) {
         CRUD::create(CRUD::$table_sign, $data);
         $sid = pdo_insertid();
     } else {
         CRUD::updateById(CRUD::$table_sign, $data, $sid);
     }
     //连续 签到处理
     $serialids = array();
     $serial_ids = $_GPC['serial_ids'];
     $serial_days = $_GPC['serial_day'];
     $serial_credits = $_GPC['serial_credit'];
     if (is_array($serial_ids)) {
         foreach ($serial_ids as $key => $value) {
             $value = intval($value);
             $d = array('sid' => $sid, 'day' => $serial_days[$key], 'credit' => $serial_credits[$key], 'createtime' => TIMESTAMP);
             if (empty($value)) {
                 CRUD::create(CRUD::$table_sign_serial, $d);
                 $serialids[] = pdo_insertid();
             } else {
                 CRUD::updateById(CRUD::$table_sign_serial, $d, $value);
                 $serialids[] = $value;
             }
         }
         if (count($serialids) > 0) {
             pdo_query("delete from " . tablename(CRUD::$table_sign_serial) . " where sid='{$sid}' and id not in (" . implode(",", $serialids) . ")");
         } else {
             pdo_query("delete from " . tablename(CRUD::$table_sign_serial) . " where sid='{$sid}' ");
         }
     }
     //快捷菜单处理
     $link_ids = $_GPC['link_ids'];
     $link_urls = $_GPC['link_url'];
     $link_names = $_GPC['link_name'];
     $link_sorts = $_GPC['link_sort'];
     pdo_query("delete from " . tablename(CRUD::$table_sign_link) . " where sid=:sid", array(":sid" => $sid));
     if (is_array($link_ids)) {
         foreach ($link_ids as $key => $value) {
             $value = intval($value);
             $d = array("sid" => $sid, "sort" => $link_sorts[$key], "link_name" => $link_names[$key], "link_url" => $link_urls[$key], 'createtime' => TIMESTAMP);
             CRUD::create(CRUD::$table_sign_link, $d);
         }
     }
     return true;
 }
开发者ID:ChainBoy,项目名称:wxfx,代码行数:49,代码来源:module.php

示例3: 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

示例4: getAccessToken

 /**
  * author: codeMonkey QQ:631872807
  * 全局access_token获取
  * @return
  */
 public function getAccessToken()
 {
     global $_W;
     $tokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $this->appid . "&secret=" . $this->secret;
     $accessToken = CRUD::findUnique(CRUD::$table_sin_token, array(":weid" => $_W['weid']));
     load()->func('communication');
     if (!empty($accessToken)) {
         $expires_in = $accessToken['expires_in'];
         if (TIMESTAMP - $accessToken['createtime'] >= $expires_in - 200) {
             // 过期
             $content = ihttp_get($tokenUrl);
             $token = @json_decode($content['content'], true);
             $data = array('weid' => $_W['weid'], 'access_token' => $token['access_token'], 'expires_in' => $token['expires_in'], 'createtime' => TIMESTAMP);
             CRUD::updateById(CRUD::$table_sin_token, $data, $accessToken['id']);
             return $token['access_token'];
         } else {
             return $accessToken['access_token'];
         }
     } else {
         $content = ihttp_get($tokenUrl);
         $token = @json_decode($content['content'], true);
         $data = array('weid' => $_W['weid'], 'access_token' => $token['access_token'], 'expires_in' => $token['expires_in'], 'createtime' => TIMESTAMP);
         CRUD::create(CRUD::$table_sin_token, $data);
         return $token['access_token'];
     }
 }
开发者ID:aspnmy,项目名称:weizan,代码行数:31,代码来源:oauth2.class.php

示例5: CRUD

<?php

// TACOPS for CRUD
include 'crud.php';
session_start();
$requests = $_POST;
$CRUD = new CRUD();
foreach ($requests as $request) {
    if ($request['type'] == 'read') {
        $query = $request['query'];
        $result = $CRUD->read($query);
    }
    if ($request['type'] == 'create') {
        $query = $request['query'];
        $result = $CRUD->create($query);
    }
    if ($request['type'] == 'update') {
        $query = $request['query'];
        $result = $CRUD->update($query);
    }
    echo $result;
}
开发者ID:stsraz,项目名称:bradApp,代码行数:22,代码来源:crudOps.php


注:本文中的CRUD::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。