本文整理匯總了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;
}
示例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;
}
示例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);
//.........這裏部分代碼省略.........
示例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'];
}
}
示例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;
}