本文整理汇总了PHP中Core::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Core::getQuery方法的具体用法?PHP Core::getQuery怎么用?PHP Core::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core::getQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: cleanCombats
/**
* Deletes old combats.
*
* @param integer $days Storing time of combats
*
* @return integer Number of delteted combats
*/
protected function cleanCombats($days)
{
$days = (int) $days;
$time = TIME - 86400 * $days;
Core::getQuery()->delete("assault", "time <= ?", null, null, array($time));
return Core::getDatabase()->affectedRows();
}
示例4: 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;
}
示例5: _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;
}
示例6: 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;
}
示例7: _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;
}
示例8: addRaceConditionFilter
/**
* Prepares expired events.
*
* @param string $raceConditionKey Race condition key
* @param int $max Maximum events to select
*
* @return Bengine_Game_Model_Collection_Event
*/
public function addRaceConditionFilter($raceConditionKey, $max = self::MAX_EVENT_EXECUTION)
{
$max = (int) $max;
Core::getQuery()->update("events", array("prev_rc" => $raceConditionKey), "prev_rc IS NULL AND time <= '" . TIME . "' ORDER BY eventid ASC LIMIT " . $max);
$this->getSelect()->where(array("e" => "prev_rc"), $raceConditionKey);
$this->addTimeOrder();
return $this;
}
示例9: removeGalaxyGarbage
/**
* Removes galaxy garbage.
*
* @return Bengine_Game_Cronjob_RemoveGalaxyGarbage
*/
protected function removeGalaxyGarbage()
{
$result = Core::getQuery()->select("galaxy g", array("g.planetid"), "LEFT JOIN " . PREFIX . "events e ON (e.destination = g.planetid OR e.planetid = g.planetid)", "g.destroyed = '1' AND e.eventid IS NULL");
foreach ($result->fetchAll() as $row) {
Core::getQuery()->delete("planet", "planetid = ?", null, null, array($row["planetid"]));
}
$result->closeCursor();
return $this;
}
示例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;
}
示例11: update
/**
* @param array $delete
* @param array $perms
* @return Bengine_Admin_Controller_Permissions
*/
protected function update(array $delete, array $perms)
{
foreach ($delete as $pid) {
Core::getQuery()->delete("permissions", "permissionid = ?", null, null, array($pid));
}
foreach ($perms as $pid) {
Core::getQuery()->update("permissions", array("permission" => Core::getRequest()->getPOST("perm_" . $pid)), "permissionid = ?", array($pid));
}
return $this;
}
示例12: clearSessions
/**
* Function to clear old sessions.
*
* @package Recipe 1.2
* @author Sebastian Noll
* @copyright Copyright (c) 2009, Sebastian Noll
* @license Proprietary
* @version $Id: ClearSessions.php 8 2010-10-17 20:55:04Z secretchampion $
*
* @param integer Delete sessions older than "days"
*
* @return void
*/
function clearSessions($days = 0)
{
if ($days > 0) {
$deldate = $days * 86400;
$and = " AND time < '" . $deldate . "'";
} else {
$and = "";
}
Core::getQuery()->delete("sessions", "logged = '0'" . $and);
return;
}
示例13: goThroughEvents
/**
* Executes expired events.
*
* @return Bengine_Game_EventHandler
*/
protected function goThroughEvents()
{
/* @var Bengine_Game_Model_Collection_Event $collection */
$collection = Game::getModel("game/event")->getCollection();
$collection->addRaceConditionFilter($this->raceConditionKey);
$collection->executeAll();
if ($collection->count() > 0) {
Core::getQuery()->delete("events", "prev_rc = ?", null, null, array($this->raceConditionKey));
}
return $this;
}
示例14: _afterSave
/**
* Saves the user data for the profile.
*
* @return Bengine_Game_Model_Profile
*/
protected function _afterSave()
{
if ($this->getUserId()) {
if ($this->getIsNew()) {
Core::getQuery()->insert("profile2user", array("profile_id" => $this->getProfileId(), "user_id" => $this->getUserId(), "data" => $this->getData()));
} else {
Core::getQuery()->update("profile2user", array("data" => $this->getData()), "profile_id = ? AND user_id = ?", array($this->getProfileId(), $this->getUserId()));
}
}
return parent::_afterSave();
}
示例15: getRank
/**
* Returns the rank for this user.
*
* @return integer
*/
public function getRank()
{
if (!$this->exists("rank")) {
$where = "(`username` < ? AND `points` >= {points}) OR `points` > {points}";
$where = str_replace("{points}", (double) $this->get("points", 0), $where);
$result = Core::getQuery()->select("user", array("COUNT(`userid`)+1 AS rank"), "", $where, "", 1, "", "", array($this->get("username")));
$this->set("rank", (int) $result->fetchColumn());
$result->closeCursor();
}
return $this->get("rank");
}