public static function getByUserId($userid) { $stm = DB::sql("SELECT * FROM `orders` WHERE `uid`=? AND status = 0"); $stm->bindValue(1, $userid, DB::PARAM_INT); $stm->execute(); return $stm->fetchAll(DB::FETCH_CLASS, __CLASS__); }
/** * Get a skin by payer name * @param $playerName String * @return Skin */ public static function getSkinByPlayerName($playerName) { $stn = DB::sql("SELECT * FROM mc_skin WHERE player_name=?"); $stn->bindValue(1, $playerName, DB::PARAM_STR); $stn->execute(); return $stn->fetchObject(__CLASS__); }
public static function queryUrl($url) { $stm = Database::sql('SELECT `id`, `alias`, `url`, `status`, `add_time`, `click_num` FROM `url_list` WHERE `url`=?'); $stm->bindValue(1, $url, Database::PARAM_STR); $stm->execute(); return $stm->fetchObject(__CLASS__); }
public static function getByTrade($trade) { $stm = DB::sql('SELECT id, trade, has_notify FROM trade WHERE trade=?'); $stm->bindValue(1, $trade); $stm->execute(); return $stm->fetchObject(__CLASS__); }
public function run() { // 清理一个月前的数据 $mon = time() - 2592000; $stn = Database::sql('DELETE FROM `card` WHERE add_time<? AND status=0'); $stn->bindValue(1, $mon, Database::PARAM_INT); $stn->execute(); $stn = Database::sql("DELETE FROM `invite` WHERE dateLine<? AND status=1"); $stn->bindValue(1, $mon, Database::PARAM_INT); $stn->execute(); }
public static function setNextRun($cronId, $step) { $inTransaction = DB::getInstance()->inTransaction(); if (!$inTransaction) { DB::getInstance()->beginTransaction(); } $st = DB::sql("UPDATE cron SET nextrun=? WHERE id=?"); $st->bindValue(1, $step, DB::PARAM_INT); $st->bindValue(2, $cronId, DB::PARAM_STR); $st->execute(); if (!$inTransaction) { DB::getInstance()->commit(); } }
public function destroy() { $inTransaction = DB::getInstance()->inTransaction(); if (!$inTransaction) { DB::getInstance()->beginTransaction(); } $st = DB::sql("UPDATE card SET status=0 WHERE card=:card"); // 失效卡 $st->bindValue(":card", $this->card, DB::PARAM_STR); $flag = $st->execute(); if (!$inTransaction) { DB::getInstance()->commit(); } return $flag; }
public function run() { $resetDate = '1'; $date = date("d", time()); if ($date == $resetDate) { $inTransaction = DB::getInstance()->inTransaction(); if (!$inTransaction) { DB::getInstance()->beginTransaction(); } $st = DB::sql("UPDATE member SET flow_up=0, flow_down=0 WHERE `enable`=1 AND `plan`!='Z'"); $st->execute(); if (!$inTransaction) { DB::getInstance()->commit(); } } return false; }
/** * Set administrator */ public function setAdmin($val) { if ($val == 1 && !$this->isAdmin()) { $stn = DB::sql("INSERT INTO `admin` SET uid=?"); $stn->bindValue(1, $this->uid, DB::PARAM_INT); $stn->execute(); } else { if ($val == 0 && $this->isAdmin()) { $stn = DB::sql("DELETE FROM `admin` WHERE uid=?"); $stn->bindValue(1, $this->uid, DB::PARAM_INT); $stn->execute(); } } }
/** * Get mail queue list on limit 2 * @return Mail */ public static function getQueueList() { $st = DB::sql("SELECT `id`,`to`,`subject`,`content` FROM mail_queue LIMIT 2"); $st->execute(); return $st->fetchAll(DB::FETCH_CLASS, __CLASS__); }
/** * Get invites by uid * @param int $uid * @param string $status * @return array */ public static function getInvitesByUid($uid = -1, $status = "") { $sql = "SELECT * FROM invite WHERE uid={$uid} "; if ($status != "") { $sql .= "AND status={$status} "; } $sql .= "ORDER BY dateLine DESC"; $stn = DB::sql($sql); $stn->execute(); return $stn->fetchAll(DB::FETCH_CLASS, __CLASS__); }