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


PHP Doctrine_Query::orWhere方法代码示例

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


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

示例1: addOrDateQuery

 protected function addOrDateQuery(Doctrine_Query $query, $field, $values)
 {
     $fieldName = $this->getFieldName($field);
     if (isset($values['is_empty']) && $values['is_empty']) {
         $query->orWhere(sprintf('%s.%s IS NULL', $query->getRootAlias(), $fieldName));
     } else {
         if (null !== $values['from'] && null !== $values['to']) {
             $query->orWhere(sprintf('%s.%s >= ? AND %s.%s <= ?', $query->getRootAlias(), $fieldName, $query->getRootAlias(), $fieldName), array($values['from'], $values['to']));
         } else {
             if (null !== $values['from']) {
                 $query->orWhere(sprintf('%s.%s >= ?', $query->getRootAlias(), $fieldName), $values['from']);
             } else {
                 if (null !== $values['to']) {
                     $query->orWhere(sprintf('%s.%s <= ?', $query->getRootAlias(), $fieldName), $values['to']);
                 }
             }
         }
     }
 }
开发者ID:bshaffer,项目名称:Donate-Nashville,代码行数:19,代码来源:BaseForm.class.php

示例2: addOrDateQuery

 protected function addOrDateQuery(Doctrine_Query $query, $fieldName, $values, $secondaryFromFieldName = null, $secondaryFromValues = null)
 {
     if (isset($values['is_empty']) && $values['is_empty']) {
         $query->orWhere(sprintf('%s.%s IS NULL', $query->getRootAlias(), $fieldName));
     } else {
         if (null !== $values['from'] && null !== $values['to']) {
             if (null !== $secondaryFromFieldName) {
                 $query->orWhere(sprintf('%s.%s > ? OR (%s.%s = ? AND %s.%s >= ?) AND %s.%s <= ?', $query->getRootAlias(), $secondaryFromFieldName, $query->getRootAlias(), $secondaryFromFieldName, $query->getRootAlias(), $fieldName, $query->getRootAlias(), $fieldName), array($secondaryFromValues['from'], $secondaryFromValues['from'], $values['from'], $values['to']));
             } else {
                 $query->orWhere(sprintf('%s.%s >= ? AND %s.%s <= ?', $query->getRootAlias(), $fieldName, $query->getRootAlias(), $fieldName), array($values['from'], $values['to']));
             }
         } else {
             if (null !== $values['from']) {
                 if (null !== $secondaryFromFieldName) {
                     $query->orWhere(sprintf('%s.%s > ? OR  (%s.%s = ? AND %s.%s >= ?)', $query->getRootAlias(), $secondaryFromFieldName, $query->getRootAlias(), $secondaryFromFieldName, $query->getRootAlias(), $fieldName), array($secondaryFromValues['from'], $secondaryFromValues['from'], $values['from']));
                 } else {
                     $query->orWhere(sprintf('%s.%s >= ?', $query->getRootAlias(), $fieldName), $values['from']);
                 }
             } else {
                 if (null !== $values['to']) {
                     $query->orWhere(sprintf('%s.%s <= ?', $query->getRootAlias(), $fieldName), $values['to']);
                 }
             }
         }
     }
 }
开发者ID:bshaffer,项目名称:Donate-Nashville,代码行数:26,代码来源:TimeResourceTable.class.php

示例3: addCondition

 /**
  * Adds a new condition to the current query
  * $filter is the value to be filtered
  * $op is the opreand to be used: =,>=, like, llike,REGEX,
  * $completeField. use the index $completField['field'] to
  * specify the field, to avoid ambiguous
  *
  * @param $filter
  * @param $op
  * @param $completeField
  * @return Bvb_Grid_Source_Doctrine
  */
 public function addCondition($filter, $op, $completeField)
 {
     $field = $completeField['field'];
     /**
      * FIX : #218
      * We need to make sure to use HAVING when there is function
      * in the select, as you cannot use these selected fields in the
      * WHERE clause, and all others will use the WHERE clause
      */
     $func = 'addWhere';
     if (strpos($field, '(') !== false) {
         $func = 'addHaving';
     }
     switch (strtolower($op)) {
         case 'sqlexp':
             $this->_query->{$func}($filter);
             break;
         case 'isnull':
             $this->_query->{$func}($field . ' IS NULL ');
             break;
         case 'isnnotull':
             $this->_query->{$func}($field . ' IS NOT NULL ');
             break;
         case 'empty':
             $this->_query->{$func}($field . " =''");
             break;
         case 'equal':
         case '=':
             $this->_query->{$func}($field . ' = ?', $filter);
             break;
         case 'regex':
             $this->_query->{$func}($field . " REGEXP ?", $filter);
             break;
         case 'rlike':
             $this->_query->{$func}($field . " LIKE ?", $filter . "%");
             break;
         case 'llike':
             $this->_query->{$func}($field . " LIKE ?", "%" . $filter);
             break;
         case '>=':
             $this->_query->{$func}($field . " >= ?", $filter);
             break;
         case '>':
             $this->_query->{$func}($field . " > ?", $filter);
             break;
         case '<>':
         case '!=':
             $this->_query->{$func}($field . " <> ?", $filter);
             break;
         case '<=':
             $this->_query->{$func}($field . " <= ?", $filter);
             break;
         case '<':
             $this->_query->{$func}($field . " < ?", $filter);
             break;
         case 'in':
             $filter = explode(',', $filter);
             $this->_query->whereIn($field, $filter);
             break;
         case '&':
         case 'and':
         case 'AND':
         case 'flag':
         case 'FLAG':
             $this->_query->{$func}($field . " & ? <> 0", $filter);
             break;
         case 'range':
             $start = substr($filter, 0, strpos($filter, '<>'));
             $end = substr($filter, strpos($filter, '<>') + 2);
             $this->_query->{$func}($field . " between ? and ?", array($start, $end));
             break;
         case '||':
             $this->_query->orWhere($field . " LIKE ?", "%" . $filter . "%");
             break;
         case 'like':
         default:
             $this->_query->{$func}($field . " LIKE ?", "%" . $filter . "%");
             break;
     }
     return $this;
 }
开发者ID:robjacoby,项目名称:xlr8u,代码行数:93,代码来源:Doctrine.php

示例4: routeTest10

 public function routeTest10(Doctrine_Query $q)
 {
     $q->orWhere($q->getRootAlias() . '.is_on_homepage = ?', 0);
     return $q->fetchOne();
 }
开发者ID:seven07ve,项目名称:vendorepuestos,代码行数:5,代码来源:ArticleTable.class.php

示例5: add_search_str

 /**
  * Add custom search query (from the get param 'q')
  *
  * @param Doctrine_Query $q
  * @param string $alias
  * @param string $search
  * @param boolean $useOr
  */
 public static function add_search_str($q, $alias, $search, $useOr = null)
 {
     $a = $alias ? "{$alias}." : "";
     $str = "({$a}bin_name like ?)";
     $params = array("%{$search}%");
     // try to also search User, if it's part of the query and has an alias
     if ($alias) {
         $parts = $q->getDqlPart('from');
         foreach ($parts as $dql) {
             if (preg_match("/{$alias}.User.*\$/", $dql, $matches)) {
                 $usr_alias = preg_replace("/{$alias}.User\\s*/", '', $matches[0]);
                 // must have alias
                 if ($usr_alias) {
                     $tmp = Doctrine_Query::create();
                     User::add_search_str($tmp, $usr_alias, $search);
                     $usrq = array_pop($tmp->getDqlPart('where'));
                     $usrp = $tmp->getFlattenedParams();
                     $str .= " or {$usrq}";
                     $params = array_merge($params, $usrp);
                 }
             }
         }
     }
     // add to query
     if ($useOr) {
         $q->orWhere($str, $params);
     } else {
         $q->addWhere($str, $params);
     }
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:38,代码来源:Bin.php


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