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


PHP Select::orWhere方法代码示例

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


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

示例1: _buildWhereClause


//.........这里部分代码省略.........
                     $select->where->greaterThanOrEqualTo('ct.montant_cotis', $this->_filters->contrib_min_amount);
                 }
                 if ($this->_filters->contrib_max_amount) {
                     $select->where->lessThanOrEqualTo('ct.montant_cotis', $this->_filters->contrib_max_amount);
                 }
             }
             if ($this->_filters->contributions_types) {
                 $select->where->in('ct.id_type_cotis', $this->_filters->contributions_types);
             }
             if ($this->_filters->payments_types) {
                 $select->where->in('ct.type_paiement_cotis', $this->_filters->payments_types);
             }
             if (count($this->_filters->contrib_dynamic) > 0 && !isset($this->_filters->contrib_dynamic['empty'])) {
                 foreach ($this->_filters->contrib_dynamic as $k => $cd) {
                     $qry = '';
                     $prefix = 'a.';
                     $field = null;
                     $qop = ' LIKE ';
                     if (is_array($cd)) {
                         //dynamic choice spotted!
                         $prefix = 'cdfc' . $k . '.';
                         $qry = 'dfc.field_form = \'contrib\' AND ' . 'dfc.field_id = ' . $k . ' AND ';
                         $field = 'id';
                     } else {
                         //dynamic field spotted!
                         $prefix = 'dfc.';
                         $qry = 'dfc.field_form = \'contrib\' AND ' . 'dfc.field_id = ' . $k . ' AND ';
                         $field = 'field_val';
                     }
                     if (is_array($cd)) {
                         $select->where->in($prefix . $field, $cd);
                     } else {
                         $qry .= 'LOWER(' . $prefix . $field . ') ' . $qop . ' ';
                         $select->where($qry . '%' . strtolower($cd) . '%');
                     }
                 }
             }
             if (count($this->_filters->free_search) > 0 && !isset($this->_filters->free_search['empty'])) {
                 foreach ($this->_filters->free_search as $fs) {
                     $fs['search'] = mb_strtolower($fs['search']);
                     $qop = null;
                     switch ($fs['qry_op']) {
                         case AdvancedMembersList::OP_EQUALS:
                             $qop = '=';
                             break;
                         case AdvancedMembersList::OP_CONTAINS:
                             $qop = 'LIKE';
                             $fs['search'] = '%' . $fs['search'] . '%';
                             break;
                         case AdvancedMembersList::OP_NOT_EQUALS:
                             $qop = '!=';
                             break;
                         case AdvancedMembersList::OP_NOT_CONTAINS:
                             $qop = 'NOT LIKE';
                             $fs['search'] = '%' . $fs['search'] . '%';
                             break;
                         case AdvancedMembersList::OP_STARTS_WITH:
                             $qop = 'LIKE';
                             $fs['search'] = $fs['search'] . '%';
                             break;
                         case AdvancedMembersList::OP_ENDS_WITH:
                             $qop = 'LIKE';
                             $fs['search'] = '%' . $fs['search'];
                             break;
                         default:
                             Analog::log('Unknown query operator: ' . $fs['qry_op'] . ' (will fallback to equals)', Analog::WARNING);
                             $qop = '=';
                             break;
                     }
                     $qry = '';
                     $prefix = 'a.';
                     if (strpos($fs['field'], 'dync_') === 0) {
                         //dynamic choice spotted!
                         $index = str_replace('dync_', '', $fs['field']);
                         $prefix = 'cdf' . $index . '.';
                         $qry = 'df.field_form = \'adh\' AND df.field_id = ' . str_replace('dync_', '', $fs['field']) . ' AND ';
                         $fs['field'] = 'val';
                     } elseif (strpos($fs['field'], 'dyn_') === 0) {
                         //dynamic field spotted!
                         $prefix = 'df.';
                         $qry = 'df.field_form = \'adh\' AND df.field_id = ' . str_replace('dyn_', '', $fs['field']) . ' AND ';
                         $fs['field'] = 'field_val';
                     }
                     if (!strncmp($fs['field'], 'bool_', strlen('bool_'))) {
                         $qry .= $prefix . $fs['field'] . $qop . ' ' . $fs['search'];
                     } else {
                         $qry .= 'LOWER(' . $prefix . $fs['field'] . ') ' . $qop . ' ' . $zdb->platform->quoteValue($fs['search']);
                     }
                     if ($fs['log_op'] === AdvancedMembersList::OP_AND) {
                         $select->where($qry);
                     } elseif ($fs['log_op'] === AdvancedMembersList::OP_OR) {
                         $select->orWhere($qry);
                     }
                 }
             }
         }
     } catch (\Exception $e) {
         Analog::log(__METHOD__ . ' | ' . $e->getMessage(), Analog::WARNING);
     }
 }
开发者ID:Killerfun,项目名称:galette,代码行数:101,代码来源:Members.php


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