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


PHP Filter::getExpression方法代码示例

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


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

示例1: text

 protected function text(Filter $filter = null)
 {
     $value = $filter === null ? '' : $filter->getExpression();
     if (is_array($value)) {
         $value = '(' . implode('|', $value) . ')';
     }
     return sprintf('<input type="text" name="%s" value="%s" />', $this->elementId('value', $filter), $value);
 }
开发者ID:trigoesrodrigo,项目名称:icingaweb2,代码行数:8,代码来源:FilterEditor.php

示例2: requireFilterColumns

 protected function requireFilterColumns(Filter $filter)
 {
     if ($filter instanceof FilterExpression) {
         if ($filter->getExpression() === '*') {
             return;
             // Wildcard only filters are ignored so stop early here to avoid joining a table for nothing
         }
         $alias = $filter->getColumn();
         $this->requireColumn($alias);
         if ($this->isCustomvar($alias)) {
             $column = $this->getCustomvarColumnName($alias);
         } else {
             $column = $this->aliasToColumnName($alias);
         }
         if (isset($this->columnsWithoutCollation[$alias])) {
             $expression = $filter->getExpression();
             if (is_array($expression)) {
                 $filter->setExpression(array_map('strtolower', $expression));
             } else {
                 $filter->setExpression(strtolower($expression));
             }
         }
         $filter->setColumn($column);
     } else {
         foreach ($filter->filters() as $filter) {
             $this->requireFilterColumns($filter);
         }
     }
 }
开发者ID:ppuschmann,项目名称:icingaweb2,代码行数:29,代码来源:IdoQuery.php

示例3: renderFilterExpression

 /**
  * Render and return the given filter expression
  *
  * @param   Filter  $filter
  *
  * @return  string
  */
 protected function renderFilterExpression(Filter $filter)
 {
     $column = $filter->getColumn();
     $sign = $filter->getSign();
     $value = $filter->getExpression();
     if (is_array($value) && $sign === '=') {
         // TODO: Should we support this? Doesn't work for blub*
         return $column . ' IN (' . $this->dbAdapter->quote($value) . ')';
     } elseif ($sign === '=' && strpos($value, '*') !== false) {
         return $column . ' LIKE ' . $this->dbAdapter->quote(preg_replace('~\\*~', '%', $value));
     } elseif ($sign === '!=' && strpos($value, '*') !== false) {
         return $column . ' NOT LIKE ' . $this->dbAdapter->quote(preg_replace('~\\*~', '%', $value));
     } else {
         return $column . ' ' . $sign . ' ' . $this->dbAdapter->quote($value);
     }
 }
开发者ID:scibi,项目名称:icingaweb2,代码行数:23,代码来源:DbConnection.php

示例4: lowerColumnsWithoutCollation

 /**
  * Recurse the given filter and ensure that any string conversion is case-insensitive
  *
  * @param Filter $filter
  */
 protected function lowerColumnsWithoutCollation(Filter $filter)
 {
     if ($filter instanceof FilterExpression) {
         if (in_array($filter->getColumn(), $this->columnsWithoutCollation) && strpos($filter->getColumn(), 'LOWER') !== 0) {
             $filter->setColumn('LOWER(' . $filter->getColumn() . ')');
             $expression = $filter->getExpression();
             if (is_array($expression)) {
                 $filter->setExpression(array_map('strtolower', $expression));
             } else {
                 $filter->setExpression(strtolower($expression));
             }
         }
     } else {
         foreach ($filter->filters() as $chainedFilter) {
             $this->lowerColumnsWithoutCollation($chainedFilter);
         }
     }
 }
开发者ID:hsanjuan,项目名称:icingaweb2,代码行数:23,代码来源:IdoQuery.php

示例5: renderFilterExpression

 /**
  * Render and return the given filter expression
  *
  * @param   Filter  $filter
  *
  * @return  string
  */
 protected function renderFilterExpression(Filter $filter)
 {
     $column = $filter->getColumn();
     $sign = $filter->getSign();
     $value = $filter->getExpression();
     if (is_array($value)) {
         if ($sign === '=') {
             return $column . ' IN (' . $this->dbAdapter->quote($value) . ')';
         } elseif ($sign === '!=') {
             return sprintf('(%1$s NOT IN (%2$s) OR %1$s IS NULL)', $column, $this->dbAdapter->quote($value));
         }
         throw new ProgrammingError('Unable to render array expressions with operators other than equal or not equal');
     } elseif ($sign === '=' && strpos($value, '*') !== false) {
         if ($value === '*') {
             // We'll ignore such filters as it prevents index usage and because "*" means anything, so whether we're
             // using a real column with a valid comparison here or just an expression which can only be evaluated to
             // true makes no difference, except for performance reasons...
             return new Zend_Db_Expr('TRUE');
         }
         return $column . ' LIKE ' . $this->dbAdapter->quote(preg_replace('~\\*~', '%', $value));
     } elseif ($sign === '!=' && strpos($value, '*') !== false) {
         if ($value === '*') {
             // We'll ignore such filters as it prevents index usage and because "*" means nothing, so whether we're
             // using a real column with a valid comparison here or just an expression which cannot be evaluated to
             // true makes no difference, except for performance reasons...
             return new Zend_Db_Expr('FALSE');
         }
         return sprintf('(%1$s NOT LIKE %2$s OR %1$s IS NULL)', $column, $this->dbAdapter->quote(preg_replace('~\\*~', '%', $value)));
     } elseif ($sign === '!=') {
         return sprintf('(%1$s != %2$s OR %1$s IS NULL)', $column, $this->dbAdapter->quote($value));
     } else {
         return sprintf('%s %s %s', $column, $sign, $this->dbAdapter->quote($value));
     }
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:41,代码来源:DbConnection.php

示例6: renderFilterExpression

 /**
  * Render and return the given filter expression
  *
  * @param   Filter  $filter
  *
  * @return  string
  */
 protected function renderFilterExpression(Filter $filter)
 {
     $column = $filter->getColumn();
     $sign = $filter->getSign();
     $value = $filter->getExpression();
     if (is_array($value)) {
         if ($sign === '=') {
             return $column . ' IN (' . $this->dbAdapter->quote($value) . ')';
         } elseif ($sign === '!=') {
             return $column . ' NOT IN (' . $this->dbAdapter->quote($value) . ')';
         }
         throw new ProgrammingError('Unable to render array expressions with operators other than equal or not equal');
     } elseif ($sign === '=' && strpos($value, '*') !== false) {
         if ($value === '*') {
             // We'll ignore such filters as it prevents index usage and because "*" means anything, anything means
             // all whereas all means that whether we use a filter to match anything or no filter at all makes no
             // difference, except for performance reasons...
             return '';
         }
         return $column . ' LIKE ' . $this->dbAdapter->quote(preg_replace('~\\*~', '%', $value));
     } elseif ($sign === '!=' && strpos($value, '*') !== false) {
         if ($value === '*') {
             // We'll ignore such filters as it prevents index usage and because "*" means nothing, so whether we're
             // using a real column with a valid comparison here or just an expression which cannot be evaluated to
             // true makes no difference, except for performance reasons...
             return $this->dbAdapter->quote(0);
         }
         return $column . ' NOT LIKE ' . $this->dbAdapter->quote(preg_replace('~\\*~', '%', $value));
     } else {
         return $column . ' ' . $sign . ' ' . $this->dbAdapter->quote($value);
     }
 }
开发者ID:kobmaki,项目名称:icingaweb2,代码行数:39,代码来源:DbConnection.php

示例7: renderFilterExpression

 /**
  * Render and return the given filter expression.
  *
  * This handles non-chain parts of the Filter.
  *
  * @param   Filter   $filter
  * @return  string
  * @throws  ProgrammingError
  */
 protected function renderFilterExpression(Filter $filter)
 {
     /** @var FilterMatch $filter (just for resolving) */
     $column = $filter->getColumn();
     $sign = $filter->getSign();
     $value = $filter->getExpression();
     // array or lists
     if (is_array($value)) {
         if ($sign === '=' || $sign === '!=') {
             return array('query_string' => array('default_field' => $column, 'query' => '"' . join('" "', $value) . '"'));
         }
         throw new ProgrammingError('Unable to render array expressions with operators other than equal or not equal');
     } elseif (strpos($value, '*') !== false) {
         if ($value === '*') {
             // (sign =) We'll ignore such filters as it prevents index usage and because "*" means anything, anything means
             // all whereas all means that whether we use a filter to match anything or no filter at all makes no
             // difference, except for performance reasons...
             // (sign !=) We'll ignore such filters as it prevents index usage and because "*" means nothing, so whether we're
             // using a real column with a valid comparison here or just an expression which cannot be evaluated to
             // true makes no difference, except for performance reasons...
             return null;
         }
         if ($sign === '=' || $sign === '!=') {
             return array('query_string' => array('default_field' => $column, 'query' => $value, 'analyze_wildcard' => true));
         }
         throw new ProgrammingError('Unable to render expressions wildcards other than equal or not equal');
     } else {
         // simple comparison via match
         if ($sign === '=' || $sign === '!=') {
             return array('match' => array($column => $value));
         } elseif (preg_match('/^[<>]=?$/', $sign)) {
             $param_map = array('>' => 'gt', '<' => 'lt', '>=' => 'gte', '<=' => 'lte');
             return array('range' => array($column => array($param_map[$sign] => $value)));
         }
         throw new ProgrammingError('Unable to render string expressions with operators other than equality and range');
     }
 }
开发者ID:Icinga,项目名称:icingaweb2-module-elasticsearch,代码行数:46,代码来源:FilterRenderer.php

示例8: addFilter

 public function addFilter(Filter $filter)
 {
     // TODO: This should be considered a quick fix only.
     //       Drop this entirely once support for Icinga\Data\Filter is available
     if ($filter->isExpression()) {
         $this->where($filter->getColumn(), $filter->getExpression());
     } elseif ($filter->isChain()) {
         foreach ($filter->filters() as $chainOrExpression) {
             $this->addFilter($chainOrExpression);
         }
     }
 }
开发者ID:JakobGM,项目名称:icingaweb2,代码行数:12,代码来源:LdapQuery.php


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