本文整理汇总了PHP中core\Model::flush方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::flush方法的具体用法?PHP Model::flush怎么用?PHP Model::flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core\Model
的用法示例。
在下文中一共展示了Model::flush方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: present
/**
* 提升用户的等级 到 多少级
*
* @param $gift int 提升等级
* @param $uid int 用户uid
*/
public function present($gift, $uid)
{
$model = new Model();
$this->setRedis();
$userinfo = $this->_redisInstance->hGetAll('huser_info:' . $uid);
// 判断是否要提升到的等级是否小于本身用户的等级了,如果小于就不提升了
if ($userinfo['lv_rich'] >= $gift) {
return true;
} else {
$lv_rich = $gift;
// 根据等级计算 对应的值
$lvs = $this->getLvRich();
$rich = $lvs[$lv_rich]['level_value'];
}
$data = array('lv_rich' => $lv_rich, 'rich' => $rich);
$result = $model->flush('video_user', $data, array('uid' => $uid));
// 更新用户的等级的redis
if ($result !== false) {
$this->_redisInstance->hset('huser_info:' . $uid, 'lv_rich', $lv_rich);
$this->_redisInstance->hset('huser_info:' . $uid, 'rich', $rich);
// 记录日志
$exp_log = array('uid' => $uid, 'exp' => $rich - $userinfo['rich'], 'type' => 1, 'status' => 2, 'roled' => $userinfo['roled'], 'admin_id' => 10000, 'init_time' => date('Y-m-d H:i:s'), 'dml_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1, 'curr_exp' => $userinfo['rich']);
$model->add('video_user_mexp', $exp_log);
return true;
}
return false;
}
示例2: check
/**
* 检查首次预约的任务
*
* @param $task
* @param $uid
*
* @return mixed
*/
public function check($task, $uid)
{
$this->task = $task;
$this->uid = $uid;
$model = new Model();
$userTask = $model->find('select * from video_task_user where vtask_id=' . $task['vtask_id'] . ' and uid=' . $uid);
$user = $model->find('select * from video_user where uid=' . $uid);
if ($task['pre_vtask_id']) {
$isDo = $model->find('select * from video_task_user where vtask_id=? and uid=?', array($task['pre_vtask_id'], $user['uid']));
// 当没有申请或者没有完成父任务时
if (!$isDo || $isDo['status'] != 1) {
return 'can_apply';
}
}
/**
* 如果没有接任务的话,就判断是否可以自动申请任务
*/
if (!$userTask) {
/**
* 只要用户满足做这个任务的条件就要插入一条数据 等待预约的验证
*/
$c = serialize(array('csc' => 0, 'update_time' => time()));
$data = array('uid' => $uid, 'vtask_id' => $task['vtask_id'], 'status' => 0, 'csc' => $c, 'apply_date' => time(), 'init_time' => date('Y-m-d H:i:s'), 'dml_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1);
$model->add('video_task_user', $data);
// 增加一个申请人数
$this->updateTaskApplicants($task);
return 'doing';
}
$ut = $userTask;
$csc = unserialize($ut['csc']);
if ($ut['status'] == 1) {
return 'all';
}
if ($ut['status'] == -1) {
return 'failed';
}
if ($ut['status'] == 0 && $csc['csc'] == 100) {
return 'success';
}
/**
* 当没有完成的时候要检查进度
*/
if ($ut['status'] == 0 && $csc['csc'] != 100) {
/**
* 检查是否完成了预约,是就更新状态
* 要求在申请任务之后 预约的才算
*/
$invite = $model->find('select * from video_room_duration where invitetime>? and reuid=?', array($ut['apply_date'], $uid));
if ($invite) {
$data = array();
$csc['csc'] = 100;
$csc['update_time'] = time();
$data['csc'] = serialize($csc);
$model->flush('video_task_user', $data, array('auto_id' => $ut['auto_id']));
return 'success';
}
return 'doing';
}
}
示例3: present
/**
* 送钻石
*
* @param $gift
* @param $uid
* @return mixed
*/
public function present($gift, $uid)
{
$model = new Model();
$this->setRedis();
$userinfo = $this->_redisInstance->hGetAll('huser_info:' . $uid);
$points = $userinfo['points'] + $gift;
$result = $model->flush('video_user', array('points' => $points), array('uid' => $uid));
if ($result !== false) {
$this->_redisInstance->hset('huser_info:' . $uid, 'points', $points);
return true;
}
return false;
}
示例4: present
/**
* 添加用户
*
* @param $gifts
* @param $uid
*/
public function present($gifts, $uid)
{
$model = new Model();
$gift = $gifts[0];
$data = array('icon_id' => $gift['id']);
$result = $model->flush('video_user', $data, array('uid' => $uid));
if ($result !== false) {
$this->setRedis();
$this->_redisInstance->hset('huser_info:' . $uid, 'icon_id', $gift['id']);
return true;
}
return false;
}
示例5: present
/**
* 添加用户的礼物到背包中
*
* @param $gifts
* @param $uid
*/
public function present($gifts, $uid)
{
$model = new Model();
$flag = false;
foreach ($gifts as $gift) {
$has_gif = $model->find('select * from video_pack where uid=? and gid=?', array($uid, $gift['id']));
if ($has_gif) {
if (!empty($gift['exp'])) {
$expires = $has_gif['expires'] + $gift['exp'] * 24 * 3600;
$model->flush('video_pack', array('expires' => $expires), array('uid' => $uid, 'gid' => $gift['id']));
}
$flag = true;
} else {
$exp = time() + $gift['exp'] * 24 * 3600;
$result = $model->add('video_pack', array('uid' => $uid, 'gid' => $gift['id'], 'num' => $gift['num'], 'expires' => $exp));
if ($result !== false) {
$flag = true;
} else {
$flag = false;
}
}
}
return $flag;
}
示例6: updateTaskAchievers
/**
* 增加完成人数
* @param $task
*/
protected function updateTaskAchievers($task)
{
$model = new Model();
$model->flush('video_task', array('achievers' => $task['achievers'] + 1), array('vtask_id' => $task['vtask_id']));
$this->delTaskRedis();
}
示例7: check
/**
* 检测邮箱任务的完成程度
*
* 邮箱如果验证了,就标示邮箱任务已经完成
* 如果在任务上线系统之前验证过的,就不用了
* 如果还没验证,就启动任务,并送礼
* @param $task
* @param $uid
*
* @return mixed
*
*/
public function check($task, $uid)
{
$this->task = $task;
$this->uid = $uid;
/**
* 获取用户对应的task_user的数据
* 如果已经验证了,但是又没有为这个用户插入这个任务的话
* 即在 任务系统上线前 就已经认证的用户 此时要插入一条完成了任务的数据
*/
$model = new Model();
$userTask = $model->find('select * from video_task_user where vtask_id=' . $task['vtask_id'] . ' and uid=' . $uid);
$user = $model->find('select * from video_user where uid=' . $uid);
if ($user['safemail'] && !$userTask) {
$c = serialize(array('csc' => 100, 'update_time' => time()));
$data = array('uid' => $uid, 'vtask_id' => $task['vtask_id'], 'status' => 1, 'csc' => $c, 'apply_date' => time(), 'init_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1);
$model->add('video_task_user', $data);
// 当完成后的加上1个完成用户
$this->updateTaskAchievers($task);
return 'all';
}
/**
* 既没验证 又没申请任务的
* 做自动申请操作 等待邮箱的安全验证
* 就返回false
*
*/
if (!$user['safemail'] && !$userTask) {
$c = serialize(array('csc' => 0, 'update_time' => time()));
$data = array('uid' => $uid, 'vtask_id' => $task['vtask_id'], 'status' => 0, 'csc' => $c, 'apply_date' => time(), 'init_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1);
$model->add('video_task_user', $data);
// 增加一个申请人数
$this->updateTaskApplicants($task);
return 'doing';
}
/**
* 完成且领取奖励
*/
if ($userTask['status'] == 1) {
return 'all';
}
/**
* 失败的
*/
if ($userTask['status'] == -1) {
return 'failed';
}
/**
* 完成了,且等待领取奖励
*/
$csc = unserialize($userTask['csc']);
if ($csc['csc'] == 100 && $userTask['status'] == 0) {
return 'success';
}
/**
* 当进度不是满的,此时要检查下完成情况
* 进行更新与否的判断和操作
* 如果用户已经完成了邮箱的验证 就更新状态
*/
if ($csc['csc'] != 100) {
if ($user['safemail']) {
$csc['csc'] = 100;
$csc['update_time'] = time();
$model->flush('video_task_user', array('csc' => serialize($csc)), array('auto_id' => $userTask['auto_id']));
return 'success';
}
return 'doing';
}
}