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


PHP Okapi::cache_size2_to_sizeid方法代码示例

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


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

示例1: prepare_common_search_params

 /**
  * Load, parse and check common geocache search parameters (the ones
  * described in services/caches/search/all method) from $this->request.
  * Most cache search methods share a common set
  * of filtering parameters recognized by this method. It initalizes
  * search params, which can be further altered by calls to other methods
  * of this class, or outside of this class by a call to get_search_params();
  *
  * This method doesn't return anything. See get_search_params method.
  */
 public function prepare_common_search_params()
 {
     $where_conds = array('true');
     $extra_tables = array();
     $extra_joins = array();
     # At the beginning we have to set up some "magic e$Xpressions".
     # We will use them to make our query run on both OCPL and OCDE databases.
     if (Settings::get('OC_BRANCH') == 'oc.pl') {
         # OCPL's 'caches' table contains some fields which OCDE's does not
         # (topratings, founds, notfounds, last_found, votes, score). If
         # we're being run on OCPL installation, we will simply use them.
         $X_TOPRATINGS = 'caches.topratings';
         $X_FOUNDS = 'caches.founds';
         $X_NOTFOUNDS = 'caches.notfounds';
         $X_LAST_FOUND = 'caches.last_found';
         $X_VOTES = 'caches.votes';
         $X_SCORE = 'caches.score';
     } else {
         # OCDE holds this data in a separate table. Additionally, OCDE
         # does not provide a rating system (votes and score fields).
         # If we're being run on OCDE database, we will include this
         # additional table in our query and we will map the field
         # expressions to approriate places.
         # stat_caches entries are optional, therefore we must do a left join:
         $extra_joins[] = 'left join stat_caches on stat_caches.cache_id = caches.cache_id';
         $X_TOPRATINGS = 'ifnull(stat_caches.toprating,0)';
         $X_FOUNDS = 'ifnull(stat_caches.found,0)';
         $X_NOTFOUNDS = 'ifnull(stat_caches.notfound,0)';
         $X_LAST_FOUND = 'ifnull(stat_caches.last_found,0)';
         $X_VOTES = '0';
         // no support for ratings
         $X_SCORE = '0';
         // no support for ratings
     }
     #
     # type
     #
     if ($tmp = $this->request->get_parameter('type')) {
         $operator = "in";
         if ($tmp[0] == '-') {
             $tmp = substr($tmp, 1);
             $operator = "not in";
         }
         $types = array();
         foreach (explode("|", $tmp) as $name) {
             try {
                 $id = Okapi::cache_type_name2id($name);
                 $types[] = $id;
             } catch (Exception $e) {
                 throw new InvalidParam('type', "'{$name}' is not a valid cache type.");
             }
         }
         if (count($types) > 0) {
             $where_conds[] = "caches.type {$operator} ('" . implode("','", array_map('mysql_real_escape_string', $types)) . "')";
         } else {
             if ($operator == "in") {
                 $where_conds[] = "false";
             }
         }
     }
     #
     # size2
     #
     if ($tmp = $this->request->get_parameter('size2')) {
         $operator = "in";
         if ($tmp[0] == '-') {
             $tmp = substr($tmp, 1);
             $operator = "not in";
         }
         $types = array();
         foreach (explode("|", $tmp) as $name) {
             try {
                 $id = Okapi::cache_size2_to_sizeid($name);
                 $types[] = $id;
             } catch (Exception $e) {
                 throw new InvalidParam('size2', "'{$name}' is not a valid cache size.");
             }
         }
         $where_conds[] = "caches.size {$operator} ('" . implode("','", array_map('mysql_real_escape_string', $types)) . "')";
     }
     #
     # status - filter by status codes
     #
     $tmp = $this->request->get_parameter('status');
     if ($tmp == null) {
         $tmp = "Available";
     }
     $codes = array();
     foreach (explode("|", $tmp) as $name) {
         try {
//.........这里部分代码省略.........
开发者ID:harrieklomp,项目名称:oc-server3,代码行数:101,代码来源:searching.inc.php


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