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


PHP ARSelectFilter::setHavingCondition方法代码示例

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


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

示例1: __construct


//.........这里部分代码省略.........
                             // convert
                             // 2010-9-1 to 2010-09-01 ( +first or last minute of day)
                             // unset dates to 'inf' (meaning ingnore condition)
                             if ($from == '') {
                                 $from = 'inf';
                             } else {
                                 list($y, $m, $d) = explode('-', $from);
                                 $from = $y . '-' . str_pad($m, 2, '0', STR_PAD_LEFT) . '-' . str_pad($d, 2, '0', STR_PAD_LEFT) . ' 00:00:00';
                             }
                             if ($to == '') {
                                 $to = 'inf';
                             } else {
                                 list($y, $m, $d) = explode('-', $to);
                                 $to = $y . '-' . str_pad($m, 2, '0', STR_PAD_LEFT) . '-' . str_pad($d, 2, '0', STR_PAD_LEFT) . ' 23:59:59';
                             }
                         } else {
                             list($from, $to) = explode(' | ', $value);
                         }
                         $cond = null;
                         // from condition
                         if ('inf' != $from) {
                             $cond = new EqualsOrMoreCond($handle, getDateFromString($from));
                         }
                         // to condition
                         if ('now' != $to && 'inf' != $to) {
                             $condTo = new EqualsOrLessCond($handle, getDateFromString($to));
                             if ($cond) {
                                 $cond->addAnd($condTo);
                             } else {
                                 $cond = $condTo;
                             }
                         }
                         if ($cond) {
                             $conds[] = $cond;
                         }
                     } else {
                         $conds[] = new LikeCond($handle, '%' . $value . '%');
                     }
                 }
             } else {
                 if (is_array($handle)) {
                     $cond = null;
                     foreach ($handle as $h) {
                         $c = new LikeCond($h, '%' . $value . '%');
                         if (!$cond) {
                             $cond = $c;
                         } else {
                             $cond->addOR($c);
                         }
                     }
                     $conds[] = $cond;
                 } else {
                     if (array_key_exists($field, $this->columnTypes)) {
                         $type = $this->columnTypes[$field]['type'];
                     } else {
                         $type = null;
                     }
                     $value = preg_replace('/[ ]{2,}/', ' ', $value);
                     switch ($type) {
                         case 'numeric':
                             $constraints = explode(' ', $value);
                             foreach ($constraints as $c) {
                                 list($operator, $value) = $this->parseOperatorAndValue($c);
                                 if (!is_numeric($value)) {
                                     continue;
                                 }
                                 $having[] = new OperatorCond($handle, $value, $operator);
                             }
                             break;
                         default:
                             $having[] = eq(new ARExpressionHandle($field), $value);
                     }
                 }
             }
         }
     }
     // apply IDs to filter
     if ($request->get('selectedIDs') || $request->get('isInverse')) {
         $selectedIDs = json_decode($request->get('selectedIDs'));
         if ($selectedIDs) {
             if ((bool) $request->get('isInverse')) {
                 $idcond = new NotINCond(new ARFieldHandle($modelClass, 'ID'), $selectedIDs);
             } else {
                 $idcond = new INCond(new ARFieldHandle($modelClass, 'ID'), $selectedIDs);
             }
             $conds[] = $idcond;
         } else {
             if (!(bool) $request->get('isInverse')) {
                 $idcond = new EqualsCond(new ARExpressionHandle(1), 2);
                 $conds[] = $idcond;
             }
         }
     }
     if ($conds) {
         $filter->setCondition(new AndChainCondition($conds));
     }
     if (!empty($having)) {
         $filter->setHavingCondition(new AndChainCondition($having));
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:101,代码来源:ActiveGrid.php


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