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


PHP SelectInterface::escapeLike方法代码示例

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


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

示例1: escapeLike

 /**
  * {@inheritdoc}
  */
 public function escapeLike($string)
 {
     return $this->query->escapeLike($string);
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:7,代码来源:SelectExtender.php

示例2: translateCondition

 /**
  * Translates the string operators to SQL equivalents.
  *
  * @param array $condition
  *   The condition array.
  * @param \Drupal\Core\Database\Query\SelectInterface $sql_query
  *   Select query instance.
  * @param bool|null $case_sensitive
  *   If the condition should be case sensitive or not, NULL if the field does
  *   not define it.
  *
  * @see \Drupal\Core\Database\Query\ConditionInterface::condition()
  */
 public static function translateCondition(&$condition, SelectInterface $sql_query, $case_sensitive)
 {
     // // There is nothing we can do for IN ().
     if (is_array($condition['value'])) {
         return;
     }
     // Ensure that the default operator is set to simplify the cases below.
     if (empty($condition['operator'])) {
         $condition['operator'] = '=';
     }
     switch ($condition['operator']) {
         case '=':
             // If a field explicitly requests that queries should not be case
             // sensitive, use the LIKE operator, otherwise keep =.
             if ($case_sensitive === FALSE) {
                 $condition['value'] = $sql_query->escapeLike($condition['value']);
                 $condition['operator'] = 'LIKE';
             }
             break;
         case '<>':
             // If a field explicitly requests that queries should not be case
             // sensitive, use the NOT LIKE operator, otherwise keep <>.
             if ($case_sensitive === FALSE) {
                 $condition['value'] = $sql_query->escapeLike($condition['value']);
                 $condition['operator'] = 'NOT LIKE';
             }
             break;
         case 'STARTS_WITH':
             if ($case_sensitive) {
                 $condition['operator'] = 'LIKE BINARY';
             } else {
                 $condition['operator'] = 'LIKE';
             }
             $condition['value'] = $sql_query->escapeLike($condition['value']) . '%';
             break;
         case 'CONTAINS':
             if ($case_sensitive) {
                 $condition['operator'] = 'LIKE BINARY';
             } else {
                 $condition['operator'] = 'LIKE';
             }
             $condition['value'] = '%' . $sql_query->escapeLike($condition['value']) . '%';
             break;
         case 'ENDS_WITH':
             if ($case_sensitive) {
                 $condition['operator'] = 'LIKE BINARY';
             } else {
                 $condition['operator'] = 'LIKE';
             }
             $condition['value'] = '%' . $sql_query->escapeLike($condition['value']);
             break;
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:66,代码来源:Condition.php

示例3: translateCondition

 /**
  * Translates the string operators to SQL equivalents.
  *
  * @param array $condition
  *   The condition array.
  * @param \Drupal\Core\Database\Query\SelectInterface $sql_query
  *   Select query instance.
  * @param bool|null $case_sensitive
  *   If the condition should be case sensitive or not, NULL if the field does
  *   not define it.
  *
  * @see \Drupal\Core\Database\Query\ConditionInterface::condition()
  */
 public static function translateCondition(&$condition, SelectInterface $sql_query, $case_sensitive)
 {
     // There is nothing to do for IN () queries except for PostgreSQL for which
     // the condition arguments need to have case lowered to support not case
     // sensitive fields.
     if (is_array($condition['value'])) {
         $entityQueryCondition = Database::getConnection()->getDriverClass('EntityQuery\\Condition');
         $entityQueryCondition::translateCondition($condition, $case_sensitive);
         return;
     }
     // Ensure that the default operator is set to simplify the cases below.
     if (empty($condition['operator'])) {
         $condition['operator'] = '=';
     }
     switch ($condition['operator']) {
         case '=':
             // If a field explicitly requests that queries should not be case
             // sensitive, use the LIKE operator, otherwise keep =.
             if ($case_sensitive === FALSE) {
                 $condition['value'] = $sql_query->escapeLike($condition['value']);
                 $condition['operator'] = 'LIKE';
             }
             break;
         case '<>':
             // If a field explicitly requests that queries should not be case
             // sensitive, use the NOT LIKE operator, otherwise keep <>.
             if ($case_sensitive === FALSE) {
                 $condition['value'] = $sql_query->escapeLike($condition['value']);
                 $condition['operator'] = 'NOT LIKE';
             }
             break;
         case 'STARTS_WITH':
             if ($case_sensitive) {
                 $condition['operator'] = 'LIKE BINARY';
             } else {
                 $condition['operator'] = 'LIKE';
             }
             $condition['value'] = $sql_query->escapeLike($condition['value']) . '%';
             break;
         case 'CONTAINS':
             if ($case_sensitive) {
                 $condition['operator'] = 'LIKE BINARY';
             } else {
                 $condition['operator'] = 'LIKE';
             }
             $condition['value'] = '%' . $sql_query->escapeLike($condition['value']) . '%';
             break;
         case 'ENDS_WITH':
             if ($case_sensitive) {
                 $condition['operator'] = 'LIKE BINARY';
             } else {
                 $condition['operator'] = 'LIKE';
             }
             $condition['value'] = '%' . $sql_query->escapeLike($condition['value']);
             break;
     }
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:70,代码来源:Condition.php


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