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


PHP Core::getDB方法代码示例

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


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

示例1: startSession

 /**
  * Start a new session and destroy old sessions.
  *
  * @return Bengine_Game_Login
  */
 public function startSession()
 {
     if ($this->canLogin) {
         Core::getDB()->query("UPDATE " . PREFIX . "user SET curplanet = hp WHERE userid = ?", array($this->userid));
     }
     return parent::startSession();
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:12,代码来源:Login.php

示例2: rebuildCache

 /**
  * Rebuilds a cache object.
  *
  * @param string $type
  * @param mixed $options
  *
  * @return void
  */
 public static function rebuildCache($type, array $options = null)
 {
     switch ($type) {
         case "config":
             Core::getCache()->buildConfigCache();
             break;
         case "lang":
             if ($options !== null && !empty($options["language"])) {
                 $result = Core::getQuery()->select("languages", array("langcode"), "", Core::getDB()->quoteInto("languageid = ?", $options["language"]));
                 $langcode = $result->fetchColumn();
                 if (!empty($options["group"])) {
                     $result = Core::getQuery()->select("phrasesgroups", array("title"), "", Core::getDB()->quoteInto("phrasegroupid = ?", $options["group"]));
                     $groupname = $result->fetchColumn();
                     Core::getCache()->cachePhraseGroup($groupname, $langcode);
                 } else {
                     Core::getCache()->cacheLanguage($langcode);
                 }
             } else {
                 $result = Core::getQuery()->select("languages", "langcode");
                 foreach ($result->fetchAll() as $row) {
                     Core::getCache()->cacheLanguage($row["langcode"]);
                 }
             }
             break;
         case "perm":
             Core::getCache()->buildPermissionCache();
             break;
     }
     return;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:38,代码来源:Admin.php

示例3: checkKey

 /**
  * Checks if the given key is ok for the userid.
  *
  * @param integer $user_id
  * @param string $key
  *
  * @return boolean
  */
 public function checkKey($user_id, $key)
 {
     $where = Core::getDB()->quoteInto("user_id = ?", $user_id);
     $where .= Core::getDB()->quoteInto(" AND feed_key = ?", $key);
     $result = Core::getQuery()->select("feed_keys", array("feed_key"), "", $where);
     return $result->rowCount() > 0;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:15,代码来源:Feed.php

示例4: _execute

 /**
  * (non-PHPdoc)
  * @see app/code/Bengine/EventHandler/Handler/Bengine_Game_EventHandler_Handler_Abstract#_execute($event, $data)
  */
 protected function _execute(Bengine_Game_Model_Event $event, array $data)
 {
     Hook::event("EhRecycling", array($event, &$data, $this));
     $where = Core::getDB()->quoteInto("galaxy = ? AND system = ? AND position = ?", array($data["galaxy"], $data["system"], $data["position"]));
     $result = Core::getQuery()->select("galaxy", array("metal", "silicon"), "", $where);
     if ($_row = $result->fetchRow()) {
         $result->closeCursor();
         $capacityMetal = (int) ($data["capacity"] * 66.7 / 100);
         $capacitySilicon = (int) ($data["capacity"] * 33.3 / 100);
         $roundFix = $data["capacity"] - $capacityMetal - $capacitySilicon;
         if ($roundFix > 0) {
             $capacitySilicon += $roundFix;
         }
         $data["debrismetal"] = $_row["metal"];
         $data["debrissilicon"] = $_row["silicon"];
         $capacitySilicon += $capacityMetal > $_row["metal"] ? $capacityMetal - $_row["metal"] : 0;
         $capacityMetal += $capacitySilicon > $_row["silicon"] ? $capacitySilicon - $_row["silicon"] : 0;
         $data["metal"] += min($capacityMetal, $_row["metal"]);
         $restMetal = $_row["metal"] - min($capacityMetal, $_row["metal"]);
         $data["silicon"] += min($capacitySilicon, $_row["silicon"]);
         $restSilicon = $_row["silicon"] - min($capacitySilicon, $_row["silicon"]);
         $data["recycledmetal"] = abs($_row["metal"] - $restMetal);
         $data["recycledsilicon"] = abs($_row["silicon"] - $restSilicon);
         if ($_row["silicon"] != 0 || $_row["metal"] != 0) {
             Core::getQuery()->update("galaxy", array("metal" => $restMetal, "silicon" => $restSilicon), "galaxy = ? AND system = ? AND position = ?", array($data["galaxy"], $data["system"], $data["position"]));
         }
     }
     new Bengine_Game_AutoMsg($event["mode"], $event["userid"], $event["time"], $data);
     $this->sendBack($data, $data["time"] + $event["time"]);
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:35,代码来源:Recycling.php

示例5: pageAction

 /**
  * Alliance page action.
  *
  * @return Bengine_Comm_Controller_Alliance
  */
 public function pageAction()
 {
     Core::getLanguage()->load("Alliance");
     Core::getTPL()->clearHTMLHeaderFiles();
     Core::getTPL()->addHTMLHeaderFile("game.css", "css");
     Core::getTPL()->addHTMLHeaderFile("lib/jquery.js", "js");
     $tag = $this->getParam("1");
     $fNumber = array("member", "points", "rpoints", "fpoints", "dpoints");
     $attr = array("a.aid", "a.name", "a.tag", "a.logo", "a.textextern", "a.homepage", "a.showhomepage", "COUNT(u2a.userid) AS member", "SUM(u.points) AS points", "SUM(u.rpoints) AS rpoints", "SUM(u.fpoints) AS fpoints", "SUM(u.dpoints) AS dpoints");
     $joins = "LEFT JOIN " . PREFIX . "user2ally u2a ON (u2a.aid = a.aid) ";
     $joins .= "LEFT JOIN " . PREFIX . "user u ON (u2a.userid = u.userid) ";
     $result = Core::getQuery()->select("alliance a", $attr, $joins, Core::getDB()->quoteInto("tag = ?", $tag), "", 1, "a.aid");
     $row = $result->fetchRow();
     if ($row) {
         foreach ($fNumber as $field) {
             $row[$field] = fNumber($row[$field]);
         }
         $parser = new Bengine_Game_Alliance_Page_Parser($row["aid"]);
         if (Str::length(strip_tags($row["textextern"])) > 0) {
             $row["textextern"] = $parser->startParser($row["textextern"]);
         } else {
             $row["textextern"] = Core::getLang()->get("WELCOME");
         }
         $row["homepage"] = $row["homepage"] != "" ? Link::get($row["homepage"], $row["homepage"], $row["homepage"]) : "";
         $row["logo"] = $row["logo"] != "" ? Image::getImage($row["logo"], "") : "";
         Hook::event("ShowPublicAlliancePage", array(&$row));
         $this->assign($row);
         $this->setIsAjax();
     } else {
         $this->setNoDisplay(true);
     }
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:38,代码来源:Alliance.php

示例6: _render

 /**
  * Renders the signature image.
  *
  * @return Bengine_Comm_Controller_Signature
  */
 protected function _render()
 {
     Core::getLang()->load("Signature");
     $config = $this->getConfig();
     $imageConfig = $config["image"];
     $user = $this->getUser();
     $img = imagecreatefrompng(AD . "img/" . $imageConfig["background"]);
     if ($imageConfig["stats"]["show"]) {
         $result = Core::getQuery()->select("user", array("userid"));
         $totalUser = fNumber($result->rowCount());
         $this->_addParamToImage($img, "stats", Core::getLang()->get("RANK") . " " . $user->getFormattedRank() . "/" . $totalUser);
     }
     if ($imageConfig["planets"]["show"]) {
         $result = Core::getQuery()->select("planet", array("planetid"), "", Core::getDB()->quoteInto("userid = ? AND ismoon = 0", $user->getUserid()));
         $planets = Core::getLang()->get("NUMBER_OF_COLONY") . " " . fNumber($result->rowCount() - 1);
         $this->_addParamToImage($img, "planets", $planets);
     }
     $this->_addParamToImage($img, "username", $user->getUsername());
     $this->_addParamToImage($img, "gameName", Core::getConfig()->get("pagetitle"));
     $this->_addParamToImage($img, "planet", $user->getHomePlanet()->getPlanetname() . " [" . $user->getHomePlanet()->getCoords(false) . "]");
     $this->_addParamToImage($img, "points", Core::getLang()->get("POINTS") . " " . $user->getFormattedPoints());
     if ($user->getAid()) {
         $this->_addParamToImage($img, "alliance", Core::getLang()->get("ALLIANCE") . " " . $user->getAlliance()->getTag());
     }
     imagepng($img, $this->getCachePath() . DIRECTORY_SEPARATOR . $this->getUserId() . self::IMAGE_FILE_EXTENSION, $imageConfig["quality"]);
     imagedestroy($img);
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:33,代码来源:Signature.php

示例7: cleanPoints

 /**
  * Recalculate the points.
  *
  * @return Bengine_Game_Cronjob_PointClean
  */
 protected function cleanPoints()
 {
     Hook::event("CleanPointsBegin");
     $_result = Core::getQuery()->select("user", "userid");
     foreach ($_result->fetchAll() as $_row) {
         $points = 0;
         $fpoints = 0;
         $dpoints = 0;
         $result = Core::getQuery()->select("planet", "planetid", "", Core::getDB()->quoteInto("userid = ?", $_row["userid"]));
         foreach ($result->fetchAll() as $row) {
             $points += Bengine_Game_PointRenewer::getBuildingPoints($row["planetid"]);
             $points += Bengine_Game_PointRenewer::getFleetPoints($row["planetid"]);
             $fpoints += Bengine_Game_PointRenewer::getFleetPoints_Fleet($row["planetid"]);
             $dpoints += Bengine_Game_PointRenewer::getDefensePoints($row["planetid"]);
         }
         $result->closeCursor();
         $points += Bengine_Game_PointRenewer::getResearchPoints($_row["userid"]);
         $points += Bengine_Game_PointRenewer::getFleetEventPoints($_row["userid"]);
         $fpoints += Bengine_Game_PointRenewer::getFleetEvent_Fleet($_row["userid"]);
         $rpoints = Bengine_Game_PointRenewer::getResearchPoints_r($_row["userid"]);
         Core::getQuery()->update("user", array("points" => $points, "fpoints" => $fpoints, "rpoints" => $rpoints, "dpoints" => $dpoints), "userid = ?", array($_row["userid"]));
     }
     $_result->closeCursor();
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:30,代码来源:PointClean.php

示例8: buildCache

 function buildCache()
 {
     $Data = Core::getDB()->query("SELECT userID, MAX(banTime) FROM " . BANNED . " WHERE banTime > " . TIMESTAMP . " GROUP BY userID;");
     $Bans = array();
     while ($Row = $Data->fetchObject()) {
         $Bans[$Row->userID] = $Row;
     }
     return $Bans;
 }
开发者ID:fuding,项目名称:Antaris,代码行数:9,代码来源:BannedBuildCache.class.php

示例9: sortPhrases

/**
 * Function to resort phrases.
 *
 * @package Recipe 1.2
 * @author Sebastian Noll
 * @copyright Copyright (c) 2009, Sebastian Noll
 * @license Proprietary
 * @version $Id: SortPhrases.php 8 2010-10-17 20:55:04Z secretchampion $
 */
function sortPhrases()
{
    Core::getDB()->query("DROP TABLE IF EXISTS " . PREFIX . "buffer");
    Core::getDB()->query("CREATE TABLE " . PREFIX . "buffer " . "(phraseid int(10) unsigned NOT NULL auto_increment, " . "languageid int(4) unsigned NOT NULL, " . "phrasegroupid int(4) unsigned NOT NULL, " . "title varchar(128) NOT NULL, " . "content text NOT NULL, " . "PRIMARY KEY (phraseid), " . "KEY languageid (languageid,phrasegroupid), " . "KEY phrasegroupid (phrasegroupid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
    Core::getDB()->query("INSERT INTO " . PREFIX . "buffer (languageid, phrasegroupid, title, content) SELECT languageid, phrasegroupid, title, content FROM " . PREFIX . "phrases ORDER BY languageid ASC, phrasegroupid ASC, title ASC");
    Core::getDB()->query("TRUNCATE TABLE " . PREFIX . "phrases");
    Core::getDB()->query("INSERT INTO " . PREFIX . "phrases (phraseid, languageid, phrasegroupid, title, content) SELECT phraseid, languageid, phrasegroupid, title, content FROM " . PREFIX . "buffer ORDER BY phraseid ASC");
    Core::getDB()->query("DROP TABLE IF EXISTS " . PREFIX . "buffer");
}
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:18,代码来源:SortPhrases.php

示例10: _remove

 /**
  * (non-PHPdoc)
  * @see app/code/Bengine/EventHandler/Handler/Bengine_Game_EventHandler_Handler_Abstract#_remove($event, $data)
  */
 protected function _remove(Bengine_Game_Model_Event $event, array $data)
 {
     $result = Core::getQuery()->select("events", array("eventid", "planetid", "destination", "start"), "", Core::getDB()->quoteInto("parent_id = ?", $event->get("eventid")));
     foreach ($result->fetchAll() as $row) {
         Core::getQuery()->update("events", array("mode" => 20, "planetid" => $row["destination"], "destination" => $row["planetid"], "time" => TIME + (TIME - $row["start"])), "eventid = ?", array($row["eventid"]));
     }
     $this->sendBack($data);
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:13,代码来源:AllianceAttack.php

示例11: editAction

 /**
  * @param integer $adId
  * @return Bengine_Admin_Controller_Commercial
  */
 protected function editAction($adId)
 {
     if ($this->isPost()) {
         $this->save($this->getParam("ad_id"), $this->getParam("name"), $this->getParam("position"), $this->getParam("max_views"), $this->getParam("enabled", 0), $this->getParam("html_code"));
     }
     $result = Core::getQuery()->select("ad", array("*"), "", Core::getDB()->quoteInto("ad_id = ?", $adId));
     $row = $result->fetchRow();
     $row["html_code"] = htmlspecialchars($row["html_code"]);
     Core::getTPL()->assign($row);
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:15,代码来源:Commercial.php

示例12: add

 /**
  * @param string $grouptitle
  * @param array $perms
  * @return Bengine_Admin_Controller_Usergroups
  */
 protected function add($grouptitle, array $perms)
 {
     Core::getQuery()->insert("usergroup", array("grouptitle" => $grouptitle, "standard" => 0));
     $groupid = Core::getDB()->lastInsertId();
     if (count($perms) > 0) {
         foreach ($perms as $permid) {
             if ($permid > 0) {
                 Core::getQuery()->insert("group2permission", array("permissionid" => $permid, "groupid" => $groupid, "value" => 1));
             }
         }
     }
     Admin::rebuildCache("perm");
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:19,代码来源:Usergroups.php

示例13: loadMenuItems

 /**
  * Loads all menu items.
  *
  * @return Bengine_Comm_CMS
  */
 protected function loadMenuItems()
 {
     $result = Core::getQuery()->select("page", array("position", "title", "label", "link"), "", Core::getDB()->quoteInto("languageid = ?", $this->langid), "displayorder ASC");
     foreach ($result->fetchAll() as $row) {
         $position = $row["position"];
         if (!empty($row["link"])) {
             $this->menuItems[$position][]["link"] = Link::get($row["link"], $row["title"], $row["title"]);
         } else {
             $this->menuItems[$position][]["link"] = Link::get(LANG . "index/" . $row["label"], $row["title"], $row["title"]);
         }
     }
     Hook::event("CommLoadMenu", array(&$this->menuItems, $this));
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:19,代码来源:CMS.php

示例14: addParticipantFilter

 /**
  * @param int|Bengine_Game_Model_User $user
  * @param int $mode
  * @return Bengine_Game_Model_Collection_Assault
  */
 public function addParticipantFilter($user, $mode = null)
 {
     if ($user instanceof Bengine_Game_Model_User) {
         $user = $user->get("userid");
     }
     $on = Core::getDB()->quoteInto("pa.assaultid = a.assaultid AND pa.userid = ?", (int) $user);
     if (null !== $mode) {
         $on .= Core::getDB()->quoteInto(" AND pa.mode = ?", (int) $mode);
     }
     $this->getSelect()->join(array("pa" => "assaultparticipant"), $on)->where("pa.userid", (int) $user);
     if (null !== $mode) {
         $this->getSelect()->where("pa.mode = ?", (int) $mode);
     }
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:20,代码来源:Assault.php

示例15: _execute

 /**
  * (non-PHPdoc)
  * @see app/code/Bengine/EventHandler/Handler/Bengine_Game_EventHandler_Handler_Abstract#_execute($event, $data)
  */
 protected function _execute(Bengine_Game_Model_Event $event, array $data)
 {
     Hook::event("EhDowngradeBuilding", array($event, &$data, $this));
     if (!$event->getPlanetid()) {
         return $this;
     }
     $points = ($data["metal"] + $data["metal"] + $data["metal"]) / 1000;
     if ($data["level"] > 0) {
         Core::getQuery()->update("building2planet", array("level" => $data["level"]), "buildingid = '" . $data["buildingid"] . "' AND planetid = ?", array($event->getPlanetid()));
     } else {
         Core::getQuery()->delete("building2planet", "buildingid = ? AND planetid = ?", null, null, array($data["buildingid"], $event->getPlanetid()));
     }
     Core::getDB()->query("UPDATE " . PREFIX . "user SET points = points - ? WHERE userid = ?", array($points, $event->getUserid()));
     return $this;
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:19,代码来源:Demolish.php


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