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


PHP Filters::buildFilters方法代码示例

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


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

示例1: getKills

 /**
  * Returns kills in json format according to the specified parameters
  *
  * @static
  * @param array $parameters
  * @return array
  */
 public static function getKills($parameters = array())
 {
     $ip = IP::get();
     $userAgent = @$_SERVER["HTTP_USER_AGENT"];
     Log::log("API Fetch: " . $_SERVER["REQUEST_URI"] . " (" . $ip . " / " . $userAgent . ")");
     $tables = array();
     $orWhereClauses = array();
     $andWhereClauses = array();
     Filters::buildFilters($tables, $orWhereClauses, $andWhereClauses, $parameters, true);
     $tables = array_unique($tables);
     //if (sizeof($tables) > 1) throw new Exception("Advanced multi-table searching is currently disabled");
     if (sizeof($tables) == 0) {
         $tables[] = "zz_participants p";
     }
     if (sizeof($tables) == 2) {
         $tablePrefix = "k";
     } else {
         $tablePrefix = substr($tables[0], strlen($tables[0]) - 1, 1);
     }
     $query = "select distinct {$tablePrefix}.killID from ";
     $query .= implode(" left join ", array_unique($tables));
     if (sizeof($tables) == 2) {
         $query .= " on (k.killID = p.killID) ";
     }
     if (sizeof($andWhereClauses) || sizeof($orWhereClauses)) {
         $query .= " where ";
         if (sizeof($orWhereClauses) > 0) {
             $andOr = array_key_exists("combined", $parameters) && $parameters["combined"] == true ? " or " : " and ";
             $query .= " ( " . implode($andOr, $orWhereClauses) . " ) ";
             if (sizeof($andWhereClauses)) {
                 $query .= " and ";
             }
         }
         if (sizeof($andWhereClauses)) {
             $query .= implode(" and ", $andWhereClauses);
         }
     }
     if (array_key_exists("limit", $parameters) && $parameters["limit"] < 200) {
         $limit = $parameters["limit"];
         $offset = 0;
     } else {
         $limit = 200;
         // Hardcoded, yes. This number should never change. -- Squizz
         $page = array_key_exists("page", $parameters) ? (int) $parameters["page"] : 1;
         $offset = ($page - 1) * $limit;
     }
     $orderDirection = array_key_exists("orderDirection", $parameters) ? $parameters["orderDirection"] : "desc";
     $query .= " order by {$tablePrefix}.dttm {$orderDirection} limit {$offset}, {$limit}";
     $cacheTime = 3600;
     $kills = Db::query($query, array(), $cacheTime);
     return self::getJSON($kills, $parameters);
 }
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:59,代码来源:Feed.php

示例2: getKills

 /**
  * Gets killmails
  *
  * @param $parameters an array of parameters to fetch mails for
  * @param $allTime gets all mails from the beginning of time or not
  * @return array
  */
 public static function getKills($parameters = array(), $allTime = true)
 {
     $tables = array();
     $orWhereClauses = array();
     $andWhereClauses = array();
     Filters::buildFilters($tables, $orWhereClauses, $andWhereClauses, $parameters, $allTime);
     $tables = array_unique($tables);
     if (sizeof($tables) == 0) {
         $tables[] = "zz_participants p";
     }
     if (sizeof($tables) == 2) {
         $tablePrefix = "k";
     } else {
         $tablePrefix = substr($tables[0], strlen($tables[0]) - 1, 1);
     }
     $query = "select distinct {$tablePrefix}.killID from ";
     $query .= implode(" left join ", array_unique($tables));
     if (sizeof($tables) == 2) {
         $query .= " on (k.killID = p.killID) ";
     }
     if (sizeof($andWhereClauses) || sizeof($orWhereClauses)) {
         $query .= " where ";
         if (sizeof($orWhereClauses) > 0) {
             $andOr = array_key_exists("combined", $parameters) && $parameters["combined"] == true ? " or " : " and ";
             $query .= " ( " . implode($andOr, $orWhereClauses) . " ) ";
             if (sizeof($andWhereClauses)) {
                 $query .= " and ";
             }
         }
         if (sizeof($andWhereClauses)) {
             $query .= implode(" and ", $andWhereClauses);
         }
     }
     $limit = array_key_exists("limit", $parameters) ? (int) $parameters["limit"] : 50;
     $page = array_key_exists("page", $parameters) ? (int) $parameters["page"] : 1;
     $offset = ($page - 1) * $limit;
     $orderBy = array_key_exists("orderBy", $parameters) ? $parameters["orderBy"] : "{$tablePrefix}.dttm";
     $orderDirection = array_key_exists("orderDirection", $parameters) ? $parameters["orderDirection"] : "desc";
     $query .= " order by {$orderBy} {$orderDirection} limit {$offset}, {$limit}";
     $cacheTime = array_key_exists("cacheTime", $parameters) ? (int) $parameters["cacheTime"] : 120;
     $cacheTime = max(120, $cacheTime);
     if (array_key_exists("log", $parameters)) {
         Db::log($query, array());
     }
     $kills = Db::query($query, array(), $cacheTime);
     $merged = self::getKillsDetails($kills);
     return $merged;
 }
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:55,代码来源:Kills.php

示例3: getSummary

 /**
  * @param string $type
  * @param string $column
  * @param array $data
  * @param integer $id
  * @param array $parameters
  * @return array
  */
 private static function getSummary($type, $column, &$data, $id, $parameters = array())
 {
     $key = "summary:{$type}:{$column}:{$id}:" . json_encode($parameters);
     $mc = Cache::get($key);
     if ($mc) {
         return $mc;
     }
     $rank = Db::queryRow("select * from zz_ranks where type = :type and typeID = :id", array(":type" => $type, ":id" => $id), 300);
     $recentRank = Db::queryField("select overallRank from zz_ranks_recent where type = :type and typeID = :id", "overallRank", array(":type" => $type, ":id" => $id), 300);
     $idCount = 0;
     foreach ($parameters as $key => $value) {
         if (Util::endsWith($key, "ID")) {
             $idCount++;
         }
     }
     if (false) {
         //isset($parameters["solo"]) || $idCount >= 2) {
         $rank = $recentRank = array();
         $tables = array();
         $whereClauses = array();
         if (!isset($parameters["kills"]) && !isset($parameters["losses"])) {
             $parameters["mixed"] = true;
         }
         Filters::buildFilters($tables, $whereClauses, $whereClauses, $parameters, true);
         $whereStatement = implode(" and ", $whereClauses);
         $query = "select groupID, sum(if(isVictim, 0, 1)) destroyed, sum(if(isVictim, 0, total_price)) iskDestroyed, sum(if(isVictim, 0, points)) pointsDestroyed, sum(if(isVictim, 1, 0)) lost, sum(if(isVictim, total_price, 0)) iskLost, sum(if(isVictim, points, 0)) pointsLost from (select vGroupID groupID, isVictim, total_price, points from zz_participants p where {$whereStatement} group by killID) as foo group by groupID";
         $stats = Db::query($query);
     } else {
         if ($type == "system" || $type == "region") {
             $stats = Db::query("select groupID, lost destroyed, 0 lost, pointsLost pointsDestroyed, 0 pointsLost, iskLost iskDestroyed, 0 iskLost from zz_stats where type='{$type}' and typeID = {$id}", array(":id" => $id), 300);
         } else {
             $stats = Db::query("select groupID, destroyed, lost, pointsDestroyed, pointsLost, iskDestroyed, iskLost from zz_stats where type='{$type}' and typeID = :id", array(":id" => $id), 0);
         }
     }
     $infoStats = array();
     $data["shipsDestroyed"] = 0;
     $data["shipsLost"] = 0;
     $data["pointsDestroyed"] = 0;
     $data["pointsLost"] = 0;
     $data["iskDestroyed"] = 0;
     $data["iskLost"] = 0;
     foreach ($stats as $stat) {
         $infoStat = Info::addInfo($stat);
         if ($infoStat["groupID"] == 0) {
             $infoStat["groupName"] = "Unknown";
         }
         $infoStats[$infoStat["groupName"]] = $infoStat;
         $data["shipsDestroyed"] += $infoStat["destroyed"];
         $data["shipsLost"] += $infoStat["lost"];
         $data["iskDestroyed"] += $infoStat["iskDestroyed"];
         $data["iskLost"] += $infoStat["iskLost"];
         $data["pointsDestroyed"] += $infoStat["pointsDestroyed"];
         $data["pointsLost"] += $infoStat["pointsLost"];
     }
     unset($stats);
     ksort($infoStats);
     $data["stats"] = $infoStats;
     if ($rank != null && $recentRank != null) {
         $rank["recentRank"] = $recentRank;
     }
     if ($rank != null) {
         $data["ranks"] = $rank;
     }
     Cache::set($key, $data, 300);
     return $data;
 }
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:74,代码来源:Summary.php


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