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


PHP SQL::getInstance方法代码示例

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


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

示例1: erase

 public static function erase()
 {
     $sql_template = "DELETE FROM sponsors WHERE vk_id = %d";
     $sql = sprintf($sql_template, UserParameters::getUserId());
     $SQLresult = SQL::getInstance()->query($sql);
     return $SQLresult;
 }
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:7,代码来源:SponsorSatellite.php

示例2: action

 public function action()
 {
     $teamLogoId = intval($this->parameters->teamLogoId);
     $teamTitle = trim($this->parameters->teamTitle);
     if (empty($teamLogoId) || empty($teamTitle)) {
         $actionResult = new ErrorPoint(ErrorPoint::CODE_SECURITY, "Не указан логотип или название команды", ErrorPoint::TYPE_USER);
         return $actionResult;
     }
     track_stats();
     // Отслеживаем производительность
     $this->teamProfile->setTeamName($teamTitle);
     $this->teamProfile->setTeamLogoId($teamLogoId);
     $actionResult = $this->teamProfile->save();
     if ($actionResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
     } else {
         SQL::getInstance()->commit();
     }
     track_stats();
     // Отслеживаем производительность
     $api = new VKapi(VK_API_SECRET, VK_API_ID, VK_MAILING_SPEED);
     $actionResult = $api->setStatus(UserParameters::getUserId(), sprintf(VK_APPLICATION_STATUS, $this->teamProfile->getTeamName()));
     track_stats();
     // Отслеживаем производительность
     if ($actionResult instanceof ErrorPoint) {
         return $actionResult;
     }
     return $actionResult;
 }
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:29,代码来源:CuztomizationController.php

示例3: action

 public function action()
 {
     $this->result['teams'] = array();
     track_stats();
     // Отслеживаем производительность
     $sql_template = "SELECT\n     *, unix_timestamp(tour_bonus_time) as tour_bonus_time \n FROM teams\n    WHERE \n%d < param_sum AND param_sum < %d AND MOD(vk_id, %d) = 0 AND able_to_choose = 1\n LIMIT 30";
     $sql = sprintf($sql_template, $this->teamProfile->getParameterSum() - GlobalParameters::ENEMY_RANGE, $this->teamProfile->getParameterSum() + GlobalParameters::ENEMY_RANGE, rand(0, 29));
     $teamResult = SQL::getInstance()->query($sql);
     if ($teamResult instanceof ErrorPoint) {
         return $teamResult;
     }
     track_stats();
     // Отслеживаем производительность
     if ($teamResult->num_rows) {
         while ($teamObject = $teamResult->fetch_object()) {
             if (empty($teamObject->user_name) || $teamObject->vk_id == $this->teamProfile->getSocialUserId()) {
                 continue;
             }
             $team = new Team();
             $team->initFromDB($teamObject);
             $chnase = Utils::detectChanceOfWin($this->teamProfile, $team);
             $teamInJSON = JSONPrepare::team($team);
             $teamInJSON["score"] = md5($chnase . $team->getSocialUserId() . SECRET_KEY);
             $this->result['teams'][] = $teamInJSON;
         }
         track_stats();
         // Отслеживаем производительность
     } else {
         $sql_template = "SELECT\n    *, unix_timestamp(tour_bonus_time) as tour_bonus_time\nFROM teams\n    WHERE\n%d < (param_sum) AND\n(param_sum) < %d AND\nMOD(vk_id, %d) = 0 and able_to_choose = 1\n LIMIT 30";
         $sql = sprintf($sql_template, $this->teamProfile->getParameterSum() - GlobalParameters::ENEMY_RANGE * 3, $this->teamProfile->getParameterSum() + GlobalParameters::ENEMY_RANGE * 3, rand(0, 29));
         $teamResult = SQL::getInstance()->query($sql);
         if ($teamResult instanceof ErrorPoint) {
             return $teamResult;
         }
         track_stats();
         // Отслеживаем производительность
         if ($teamResult->num_rows) {
             while ($teamObject = $teamResult->fetch_object()) {
                 if (empty($teamObject->user_name) || $teamObject->vk_id == $this->teamProfile->getSocialUserId()) {
                     continue;
                 }
                 $team = new Team();
                 $team->initFromDB($teamObject);
                 $teamInJSON = JSONPrepare::team($team);
                 $chnase = Utils::detectChanceOfWin($this->teamProfile, $team);
                 //$teamInJSON["score"] = Utils::detectChanceOfWin($this->teamProfile, $team);
                 $teamInJSON["score"] = md5($chnase . $team->getSocialUserId() . SECRET_KEY);
                 $this->result['teams'][] = $teamInJSON;
             }
             track_stats();
             // Отслеживаем производительность
         }
     }
 }
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:54,代码来源:EnemyController.php

示例4: update

 public static function update($report_)
 {
     Logger::debug('main', "Abstract_ReportSession::update");
     $SQL = SQL::getInstance();
     $report = Abstract_ReportSession::load($report_->getID());
     if (!is_object($report)) {
         Logger::debug('main', "Abstract_ReportSession::updateSession failed to load report " . $report_->getID());
         return false;
     }
     $ret = $SQL->DoQuery('UPDATE @1 SET @2=%3,@4=%5,@6=%7 WHERE @8 = %9 LIMIT 1', $SQL->prefix . 'sessions_history', 'stop_why', $report_->stop_why, 'user', $report_->user, 'server', $report_->server, 'id', $report_->getID());
     return $ret;
 }
开发者ID:skdong,项目名称:nfs-ovd,代码行数:12,代码来源:Abstract_ReportSession.class.php

示例5: getTodayPayments

 private function getTodayPayments()
 {
     track_stats();
     // Отслеживаем производительность
     $sql_template = "SELECT SUM(payments.values) as summer FROM payments WHERE paymant_date > '%s 00:00:00';";
     $sql = sprintf($sql_template, date("Y-m-d"));
     $onLineResult = SQL::getInstance()->query($sql);
     if ($onLineResult instanceof ErrorPoint) {
         return $onLineResult;
     }
     track_stats();
     // Отслеживаем производительность
     $object = $onLineResult->fetch_object();
     $this->result['todayPayments'] = intval($object->summer);
 }
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:15,代码来源:SystemController.php

示例6: load_partial

 public static function load_partial($t0_, $t1_)
 {
     $sql = SQL::getInstance();
     $sql->DoQuery('SELECT * FROM #1 WHERE @2 BETWEEN %3 AND %4 ORDER BY @2 ASC;', self::table, 'timestamp', date('c', $t0_), date('c', $t1_));
     $rows = $sql->FetchAllResults();
     $reports = array();
     foreach ($rows as $row) {
         $report = self::generateFromRow($row);
         if (!is_object($report)) {
             continue;
         }
         $reports[] = $report;
     }
     return $reports;
 }
开发者ID:bloveing,项目名称:openulteo,代码行数:15,代码来源:Abstract_ReportServer.class.php

示例7: action

 public function action()
 {
     $actionResult = NULL;
     track_stats();
     // Отслеживаем производительность
     $stadiumInstance = new Stadium();
     $stadiumInstance->initById($this->parameters->stadiumId);
     track_stats();
     // Отслеживаем производительность
     if ($stadiumInstance instanceof ErrorPoint) {
         return $stadiumInstance;
     }
     if ($this->parameters->isInGame && $stadiumInstance->getRequiredLevel() > $this->teamProfile->getLevel()) {
         return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Для соверщения этой операции недостаточно уровня. У Вас " . $this->teamProfile->getLevel() . ", а необходим " . $structure->getRequiredLevel(), ErrorPoint::TYPE_USER);
     }
     if ($this->parameters->isInGame) {
         if ($stadiumInstance->getPrice() > $this->teamProfile->getMoney()) {
             return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Недостаточно денежных средств", ErrorPoint::TYPE_USER);
         }
     } else {
         if ($stadiumInstance->getRealPrice() > $this->teamProfile->getRealMoney()) {
             return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Недостаточно денежных средств", ErrorPoint::TYPE_USER);
         }
     }
     track_stats();
     // Отслеживаем производительность
     SQL::getInstance()->autocommit(false);
     track_stats();
     // Отслеживаем производительность
     if ($this->teamProfile->getStadiumId() == $stadiumInstance->getId()) {
         return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Вы уже приобрели выбранный стадион позже", ErrorPoint::TYPE_USER);
     }
     $this->teamProfile->setStadiumInstance($stadiumInstance);
     if ($this->parameters->isInGame) {
         $this->teamProfile->setMoney($this->teamProfile->getMoney() - $stadiumInstance->getPrice());
     } else {
         $this->teamProfile->setRealMoney($this->teamProfile->getRealMoney() - $stadiumInstance->getRealPrice());
     }
     $actionResult = $this->teamProfile->save();
     if ($actionResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
     } else {
         SQL::getInstance()->commit();
     }
     track_stats();
     // Отслеживаем производительность
     return $actionResult;
 }
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:48,代码来源:BuyStadiumController.php

示例8: save

 public function save()
 {
     $sql_template = "INSERT INTO sponsors (\n    sponsor_id,\n    vk_id\n) VALUES (\n    %d,\n    %d\n)";
     $sql = sprintf($sql_template, $this->getId(), UserParameters::getUserId());
     $SQLResult = SQL::getInstance()->query($sql);
     if ($SQLResult instanceof ErrorPoint) {
         return $SQLResult;
     }
     $sponsor = RAM::getInstance()->getSponsorById($this->getId(), UserParameters::getUserId());
     if (empty($sponsor)) {
         $currentIndex = RAM::getInstance()->getMaxObjectIndexForTeam(UserParameters::getUserId(), RAM::RAM_TYPE_SPONSOR);
         RAM::getInstance()->setSponsor($this, UserParameters::getUserId(), $currentIndex);
     } else {
         RAM::getInstance()->setSponsor($this, UserParameters::getUserId());
     }
 }
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:16,代码来源:Sponsor.php

示例9: load_limited

 public static function load_limited($number_, $offset_ = 0)
 {
     Logger::debug('main', 'Starting Abstract_AdminAction::load_limited');
     $SQL = SQL::getInstance();
     $SQL->DoQuery('SELECT * FROM #1 ORDER BY @2 DESC LIMIT ' . intval($number_) . ' OFFSET ' . intval($offset_), self::table, 'when');
     $rows = $SQL->FetchAllResults();
     $actions = array();
     foreach ($rows as $row) {
         $action = self::generateFromRow($row);
         if (!is_object($action)) {
             continue;
         }
         $actions[] = $action;
     }
     return $actions;
 }
开发者ID:bloveing,项目名称:openulteo,代码行数:16,代码来源:Abstract_AdminAction.class.php

示例10: accountingStatistic

 public function accountingStatistic($statistic)
 {
     return;
     $SQL = '';
     if ($statistic->mainMenu) {
         foreach ($statistic->mainMenu as $mainMenu => $count) {
             $SQL .= "update statistic_main_menu set stat_count_click = (stat_count_click + " . intval($count) . ") where stat_name = '{$mainMenu}';\r\n ";
         }
     }
     if ($statistic->shopItems) {
         foreach ($statistic->shopItems as $itemStatId => $itemStat) {
             $SQL .= "\nINSERT INTO statistic_shop (stat_id, stat_count_click, stat_count_hover) VALUES (" . $itemStatId . ", " . $itemStat->clk . ", " . $itemStat->hvr . ")\nON DUPLICATE KEY UPDATE stat_count_click = stat_count_click + " . $itemStat->clk . ", stat_count_hover = stat_count_hover + " . $itemStat->hvr . " ;\r\n\n";
         }
     }
     SQL::getInstance()->query($SQL);
 }
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:16,代码来源:Controller.php

示例11: action

 public function action()
 {
     $friendId = intval($this->parameters->friendId);
     if (empty($friendId)) {
         $actionResult = new ErrorPoint(ErrorPoint::CODE_SECURITY, "Получен не правильный номер друга", ErrorPoint::TYPE_USER);
         return $actionResult;
     }
     track_stats();
     // Отслеживаем производительность
     $actionResult = TeamSatellite::isAvailableToPrize($friendId);
     if ($actionResult instanceof ErrorPoint) {
         return $actionResult;
     }
     if ($actionResult === false) {
         return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Выбранному пользователю вы уже дарили подарок. Теперь только завтра", ErrorPoint::TYPE_USER);
     }
     track_stats();
     // Отслеживаем производительность
     SQL::getInstance()->autocommit(false);
     if ($actionResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
         return $actionResult;
     }
     track_stats();
     // Отслеживаем производительность
     $actionResult = TeamSatellite::cratePrizeDateLabel($friendId);
     if ($actionResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
         return $actionResult;
     }
     track_stats();
     // Отслеживаем производительность
     $actionResult = TeamSatellite::prizeStudyPoint($friendId);
     if ($actionResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
         return $actionResult;
     }
     SQL::getInstance()->commit();
     track_stats();
     // Отслеживаем производительность
     $api = new VKapi(VK_API_SECRET, VK_API_ID, VK_MAILING_SPEED);
     $api->setCounter($friendId, TeamSatellite::getPrizeStudyPoint($friendId));
     return $actionResult;
 }
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:44,代码来源:SendGiftController.php

示例12: initById

 public function initById($stadiumId)
 {
     $stadiumPrototype = RAM::getInstance()->getStadiumPrototypeById($stadiumId);
     if (empty($stadiumPrototype)) {
         $sql_template = "SELECT * FROM item_stadiums WHERE id = '%s'";
         $sql = sprintf($sql_template, intval($stadiumId));
         $SQLresult = SQL::getInstance()->query($sql);
         if ($SQLresult instanceof ErrorPoint) {
             return $SQLresult;
         }
         if ($SQLresult->num_rows) {
             $object = $SQLresult->fetch_object();
             $this->initFromParameters($object);
             RAM::getInstance()->setStadiumPrototype($object);
         } else {
             return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Не найден стадион по указаному номеру ", ErrorPoint::TYPE_SYSTEM);
         }
     } else {
         $this->initFromParameters($stadiumPrototype);
     }
 }
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:21,代码来源:Stadium.php

示例13: action

 public function action()
 {
     track_stats();
     // Отслеживаем производительность
     $actionResult = NULL;
     $superId = intval($this->parameters->footballerId);
     $footballerInstance = $this->teamProfile->getFootballerById($superId);
     if (empty($footballerInstance)) {
         return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Выбранный футболист не найден в вашей команде", ErrorPoint::TYPE_USER);
     }
     $footballerPricePromotion = GlobalParameters::SUPER_PRICE;
     if ($this->teamProfile->getRealMoney() < $footballerPricePromotion) {
         return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Недостаточно средств для совершения этих действий", ErrorPoint::TYPE_USER);
     }
     if ($footballerInstance->getIsSuper()) {
         return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Данный футболист уже являться фаворитным", ErrorPoint::TYPE_USER);
     }
     track_stats();
     // Отслеживаем производительность
     SQL::getInstance()->autocommit(false);
     $footballerInstance->setAsSuper(true);
     $actionResult = $footballerInstance->update();
     if ($actionResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
         return $actionResult;
     }
     track_stats();
     // Отслеживаем производительность
     $this->teamProfile->setRealMoney($this->teamProfile->getRealMoney() - $footballerPricePromotion);
     $actionResult = $this->teamProfile->save();
     if ($actionResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
     } else {
         SQL::getInstance()->commit();
     }
     track_stats();
     // Отслеживаем производительность
     return $actionResult;
 }
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:39,代码来源:SetSuperController.php

示例14: action

 public function action()
 {
     $actionResult = NULL;
     $isInGame = $this->parameters->isInGame;
     $paymentId = $this->parameters->paymentId;
     if (!array_key_exists($paymentId, $this->payments)) {
         return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Не выбран тип покупки", ErrorPoint::TYPE_USER);
     }
     $paymentInstance = $this->payments[$paymentId];
     if ($isInGame) {
         if ($paymentInstance->price > $this->teamProfile->getMoney()) {
             return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Недостаточно денежных средств", ErrorPoint::TYPE_USER);
         }
     } else {
         if ($paymentInstance->realPrice > $this->teamProfile->getRealMoney()) {
             return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Недостаточно денежных средств", ErrorPoint::TYPE_USER);
         }
     }
     track_stats();
     // Отслеживаем производительность
     SQL::getInstance()->autocommit(false);
     $this->teamProfile->setStudyPoints($this->teamProfile->getStudyPoints() + $paymentInstance->studyCount);
     if ($this->parameters->isInGame) {
         $this->teamProfile->setMoney($this->teamProfile->getMoney() - $paymentInstance->price);
     } else {
         $this->teamProfile->setRealMoney($this->teamProfile->getRealMoney() - $paymentInstance->realPrice);
     }
     $actionResult = $this->teamProfile->save();
     if ($actionResult instanceof ErrorPoint) {
         SQL::getInstance()->rollback();
     } else {
         SQL::getInstance()->commit();
     }
     track_stats();
     // Отслеживаем производительность
     return $actionResult;
 }
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:37,代码来源:BuyStudyPointsController.php

示例15: usleep

        $apiResult = NULL;
        $apiResult = $api->sendNotification($teamObject->vk_id, $notify_message);
        usleep(VK_MAILING_SPEED);
        /*      $teamId = $teamObject->vk_id; echo $teamId . "\n";
                $team = RAM::getInstance()->getTeamById($teamId);
                if(!empty($team)){
                    RAM::getInstance()->changeTeamField($teamId, 'tourBonus', $bonus);
                    RAM::getInstance()->changeTeamField($teamId, 'tourBonusTime', 0);
                }*/
    }
}
//////////////////// Это подготовка к новому //////////////////
TourSatellite::setTimerDate(time(), time() + 5 * 24 * 60 * 60, TOUR_NOTIFY_NEW);
$sql_template = "UPDATE teams SET tour_notify = " . TOUR_NOTIFY_NEW . ", tour_III = 0;";
// tour_III = 0
$SQLResultTeams = SQL::getInstance()->query($sql_template);
/*
//////////////////// Обновляем всех в памяти //////////////////

$sql_template = "SELECT vk_id FROM teams ;";
$sql = $sql_template;

$SQLresultSeelctTeam = SQL::getInstance()->query($sql);
if($SQLresultSeelctTeam instanceof ErrorPoint){
    return $SQLresultSeelctTeam;
}

echo "Upgrading for All users, count records: " . $SQLresultSeelctTeam->num_rows . " teams"  . PHP_EOL ;

if($SQLresultSeelctTeam->num_rows){
开发者ID:rootree,项目名称:vk-footboller-server,代码行数:30,代码来源:cron.closeTourIII.php


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