本文整理匯總了PHP中core\Model類的典型用法代碼示例。如果您正苦於以下問題:PHP Model類的具體用法?PHP Model怎麽用?PHP Model使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Model類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: check
/**
* 檢查簽到任務
*
* @param array $task
* @param int $uid
*
* @return mixed
*/
public function check($task, $uid)
{
$this->task = $task;
$this->uid = $uid;
/**
* 簽到任務是否以前簽過到了
*/
$model = new Model();
$check_sign = $model->find('select * from video_user_check_sign where uid=:uid', array('uid' => $uid));
if (!$check_sign) {
return 'can_apply';
}
if ($task['relatedid']) {
$isDo = $model->find('select * from video_task_user where relatedid=? and uid=?', array($task['relatedid'], $user['uid']));
// 當沒有申請或者沒有完成父任務時
if (!$isDo || $isDo['status'] != 1) {
return 'can_apply';
}
}
/**
* 計算差值
*/
$s = date('Ymd', time()) - date('Ymd', strtotime($check_sign['last_time']));
if ($s == 0) {
return 'all';
}
if ($s >= 1) {
return 'can_apply';
}
}
示例2: checkTask
/**
* 檢測用戶任務對應的狀態的問題
* @param $task array 某條任務
* @param $uid int 某個用戶
*
* @return mixed
* <p>
* 返回 FALSE 則表示任務失敗
* 返回 TRUE 則表示任務用戶可以做
* 返回 array進度的數組 則根據情況更新
* </p>
*/
public function checkTask($task, $uid)
{
$this->task = $task;
$this->user = $uid;
/**
* 當為period 為 0 一次性的任務的時候 判斷是否已經完成
* 後麵各種任務腳本中就不用再判斷此任務了
*/
if ($task['period'] == 0) {
$model = new Model();
$taskUser = $model->find('select * from video_task_user where vtask_id=' . $task['vtask_id'] . ' and uid=' . $uid);
// 當task_user 的status 為 1的時候就表示完成且領獎了
if ($taskUser && $taskUser['status'] == 1) {
return 'all';
}
}
/**
* 進行檢查和更新各個任務的狀態 調用各任務腳本
*/
$script = $task['script_name'];
$className = 'App\\Service\\Task\\TaskScript\\' . ucfirst($this->script[$script]);
// 暫時做了doctrine($this->em)的手動注入 未走service
$class = new $className();
return $class->check($task, $uid);
}
示例3: 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;
}
示例4: present
/**
* 添加用戶的禮物到背包中
*
* @param $gifts
* @param $uid
*/
public function present($gifts, $uid)
{
// 暫時性的屏蔽掉
return true;
$model = new Model();
$gift = $gifts[0];
$data = array('uid' => $uid, 'icon_id' => $gift['id'], 'type' => 1, 'init_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1);
$model->add('video_user_icon', $data);
}
示例5: getLvRich
/**
* 獲取等級對應的經驗的值
*
* @return array
*/
protected function getLvRich()
{
$model = new Model();
$lvs = $model->findAll('select * from video_level_rich');
$data = array();
foreach ($lvs as $lv) {
$data[$lv['level_id']] = $lv;
}
return $data;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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';
}
}
示例9: 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;
}
示例10: __construct
public function __construct($OSE = array(), $FROM = self::FROM_BDD)
{
parent::__construct();
$this->teatre = array("te_id" => 0, "te_nom" => "", "te_nomVisible" => "", "te_configuracio" => 0);
switch ($FROM) {
case self::FROM_BDD:
foreach ($this->teatre as $K => $V) {
$this->teatre[$K] = $OSE[$K];
if ($K == 'te_configuracio') {
$this->teatre['te_configuracio'] = json_decode($OSE['te_configuracio'], true);
}
}
break;
case self::FROM_JSON:
$S = $OSE['teatre'];
foreach ($this->teatre as $K => $V) {
if (!isset($S[$K])) {
throw new MyException("Falta entrar el camp, {$K}");
} else {
$this->teatre[$K] = $S[$K];
//if($K == 'te_configuracio') $this->teatre['te_configuracio'] = json_encode($S[$K]);
}
}
break;
case self::FROM_EMPTY:
$this->teatre['te_id'] = 0;
break;
}
}
示例11: __construct
public function __construct($OT = array(), $FROM = self::FROM_BDD)
{
parent::__construct();
$this->espectacle['e_id'] = 0;
$this->espectacle['e_Titol'] = '';
$this->espectacle['e_SrcMin'] = '';
$this->espectacle['e_Resum'] = '';
$this->espectacle['e_Tipus'] = '';
$this->espectacle['e_Html'] = '';
$this->espectacle['e_Imatge'] = '';
$this->espectacle['e_OrganitzadorCif'] = '';
$this->espectacle['e_OrganitzadorNom'] = '';
$this->espectacle['e_Correcte'] = 0;
$this->espectacle['e_Companyia'] = "";
switch ($FROM) {
case self::FROM_BDD:
foreach ($this->espectacle as $K => $V) {
$this->espectacle[$K] = $OT[$K];
}
break;
case self::FROM_JSON:
foreach ($this->espectacle as $K => $V) {
$this->espectacle[$K] = $OT['espectacle'][$K];
}
break;
case self::FROM_EMPTY:
$this->espectacle['e_id'] = 0;
break;
}
}
示例12: __construct
public function __construct($OT = NULL, $FROM = self::FROM_EMPTY)
{
parent::__construct();
$this->localitat['l_zona'] = 0;
$this->localitat['l_fila'] = 0;
$this->localitat['l_seient'] = 0;
$this->localitat['l_idSessio'] = 0;
$this->localitat['l_estat'] = '';
$this->localitat['l_pagament'] = '';
$this->localitat['l_data'] = '';
$this->localitat['l_idComanda'] = 0;
$this->localitat['l_idPreu'] = '';
$this->localitat['l_codi'] = '';
$this->localitat['l_horaArribada'] = NULL;
$this->extres['isNew'] = false;
switch ($FROM) {
case self::FROM_BDD:
foreach ($this->localitat as $K => $V) {
$this->localitat[$K] = $OT[$K];
}
$this->localitat['l_idPreu'] = json_decode($this->localitat['l_idPreu'], true);
$this->localitat['nom_seient'] = $this->localitat['l_zona'] . '-' . $this->localitat['l_fila'] . '-' . $this->localitat['l_seient'];
$this->localitat['nom_estat'] = $this->estats[$this->localitat['l_estat']];
break;
case self::FROM_JSON:
foreach ($this->localitat as $K => $V) {
$this->localitat[$K] = $OT['localitat'][$K];
}
break;
case self::FROM_EMPTY:
break;
}
}
示例13:
/**
* Call the parent construct
*/
function __construct()
{
parent::__construct();
$this->moviesql = 'SELECT * FROM ' . PREFIX . 'movie';
$this->yearsql = 'SELECT ' . PREFIX . 'movie.title,
' . PREFIX . 'movie.description,
' . PREFIX . 'movie.seoname
FROM ' . PREFIX . 'movie_year
INNER JOIN ' . PREFIX . 'movie
ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_year.movie_id
INNER JOIN ' . PREFIX . 'yr
ON ' . PREFIX . 'yr.id = ' . PREFIX . 'movie_year.year_id
WHERE ' . PREFIX . 'yr.yr=:yr';
$this->actorsql = 'SELECT ' . PREFIX . 'movie.title,
' . PREFIX . 'movie.description,
' . PREFIX . 'movie.seoname
FROM ' . PREFIX . 'movie_actor
INNER JOIN ' . PREFIX . 'movie
ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_actor.movie_id
INNER JOIN ' . PREFIX . 'actor
ON ' . PREFIX . 'actor.id = ' . PREFIX . 'movie_actor.actor_id
WHERE ' . PREFIX . 'actor.actorseo=:actor';
$this->genresql = 'SELECT ' . PREFIX . 'movie.title,
' . PREFIX . 'movie.description,
' . PREFIX . 'movie.seoname
FROM ' . PREFIX . 'movie_genre
INNER JOIN ' . PREFIX . 'movie
ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_genre.movie_id
INNER JOIN ' . PREFIX . 'genre
ON ' . PREFIX . 'genre.id = ' . PREFIX . 'movie_genre.genre_id
WHERE ' . PREFIX . 'genre.seogenre=:genre';
$this->countrysql = 'SELECT ' . PREFIX . 'movie.title,
' . PREFIX . 'movie.description,
' . PREFIX . 'movie.seoname
FROM ' . PREFIX . 'movie_origin
INNER JOIN ' . PREFIX . 'movie
ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_origin.movie_id
INNER JOIN ' . PREFIX . 'origin
ON ' . PREFIX . 'origin.id = ' . PREFIX . 'movie_origin.origin_id
WHERE ' . PREFIX . 'origin.countryseo=:country';
$this->languagesql = 'SELECT ' . PREFIX . 'movie.title,
' . PREFIX . 'movie.description,
' . PREFIX . 'movie.seoname
FROM ' . PREFIX . 'movie_languages
INNER JOIN ' . PREFIX . 'movie
ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_languages.movie_id
INNER JOIN ' . PREFIX . 'language
ON ' . PREFIX . 'language.id = ' . PREFIX . 'movie_languages.language_id
WHERE ' . PREFIX . 'language.languageseo=:language';
$this->ratingsql = 'SELECT ' . PREFIX . 'movie.title,
' . PREFIX . 'movie.description,
' . PREFIX . 'movie.seoname
FROM ' . PREFIX . 'movie_rating
INNER JOIN ' . PREFIX . 'movie
ON ' . PREFIX . 'movie.id = ' . PREFIX . 'movie_rating.movie_id
INNER JOIN ' . PREFIX . 'rating
ON ' . PREFIX . 'rating.id = ' . PREFIX . 'movie_rating.rating_id
WHERE ' . PREFIX . 'rating.seorating=:rating';
}
示例14: __construct
public function __construct($OSE = array(), $FROM = self::FROM_BDD)
{
parent::__construct();
$this->sessio = array("s_id" => 0, "s_idEspectacle" => 0, "s_idTeatre" => 0, "s_Preus" => array(), "s_SeientsLliures" => 0, "s_Localitats" => 0, "s_DataHora" => 0, "s_Correcte" => 0, "s_VisibleWeb" => 0, "s_PermetCompraOnline" => 1, "s_NomesCompraAmics" => 0, "s_DataHoraCompra" => 0);
$this->espectacle = new EspectacleTableObject(null, EspectacleTableObject::FROM_EMPTY);
switch ($FROM) {
case self::FROM_BDD:
foreach ($this->sessio as $K => $V) {
$this->sessio[$K] = $OSE[$K];
}
if (isset($OSE['e_Titol'])) {
$this->espectacle = new EspectacleTableObject($OSE, EspectacleTableObject::FROM_BDD);
}
$this->generaExtres();
break;
case self::FROM_JSON:
$S = $OSE['sessio'];
foreach ($this->sessio as $K => $V) {
if (!isset($S[$K])) {
throw new MyException("Falta entrar el camp, {$K}");
} else {
$this->sessio[$K] = $S[$K];
}
}
$this->sessio['s_Preus'] = json_encode($this->sessio['s_Preus']);
$this->generaExtres();
break;
case self::FROM_FORM:
$S = $OSE['sessio'];
foreach ($this->sessio as $K => $V) {
if (!isset($S[$K])) {
throw new MyException("Falta entrar el camp, {$K}");
} else {
$this->sessio[$K] = $S[$K];
}
}
if (!isset($OSE['sessio']['tmp_Hora']) || !isset($OSE['sessio']['tmp_Dia'])) {
throw new MyException("Has d'entrar algun dia i hora per la sessió.");
} else {
//Guardo el dia i hora de la sessió
$this->sessio['tmp_Hora'] = $OSE['sessio']['tmp_Hora'];
$this->sessio['tmp_Dia'] = $OSE['sessio']['tmp_Dia'];
$this->sessio['s_Preus'] = json_encode($this->sessio['s_Preus']);
}
if (!isset($OSE['sessio']['tmp_HoraCompra']) || empty($OSE['sessio']['tmp_HoraCompra']) || !isset($OSE['sessio']['tmp_DiaCompra']) || empty($OSE['sessio']['tmp_DiaCompra'])) {
throw new MyException("Has d'entrar algun dia i hora per començar a vendre entrades.");
} else {
//Guardo el dia i hora de la sessió
$this->sessio['tmp_HoraCompra'] = $OSE['sessio']['tmp_HoraCompra'];
$this->sessio['tmp_DiaCompra'] = $OSE['sessio']['tmp_DiaCompra'];
}
$this->generaExtres(self::FROM_FORM);
break;
case self::FROM_EMPTY:
$this->sessio['s_id'] = 0;
$this->sessio['s_Preus'] = array();
break;
}
}
示例15: mkdir
function __construct()
{
parent::__construct();
$this->pathcache = ROOT . DS . "cache" . DS . "iso3166";
if (!file_exists($this->pathcache)) {
mkdir($this->pathcache);
}
}