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


PHP xPDOQuery::having方法代码示例

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


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

示例1: addWhere

 /**
  * Adds where and having conditions
  */
 public function addWhere()
 {
     $time = microtime(true);
     $where = array();
     if (!empty($this->config['where'])) {
         $tmp = $this->config['where'];
         if (is_string($tmp) && ($tmp[0] == '{' || $tmp[0] == '[')) {
             $tmp = $this->modx->fromJSON($tmp);
         }
         if (!is_array($tmp)) {
             $tmp = array($tmp);
         }
         $where = $this->replaceTVCondition($tmp);
     }
     $where = $this->additionalConditions($where);
     if (!empty($where)) {
         $this->query->where($where);
         $condition = array();
         foreach ($where as $k => $v) {
             if (is_array($v)) {
                 if (isset($v[0])) {
                     $condition[] = is_array($v) ? $k . '(' . implode(',', $v) . ')' : $k . '=' . $v;
                 } else {
                     foreach ($v as $k2 => $v2) {
                         $condition[] = is_array($v2) ? $k2 . '(' . implode(',', $v2) . ')' : $k2 . '=' . $v2;
                     }
                 }
             } else {
                 $condition[] = $k . '=' . $v;
             }
         }
         $this->addTime('Added where condition: <b>' . implode(', ', $condition) . '</b>', microtime(true) - $time);
     }
     $time = microtime(true);
     if (!empty($this->config['having'])) {
         $tmp = $this->config['having'];
         if (is_string($tmp) && ($tmp[0] == '{' || $tmp[0] == '[')) {
             $tmp = $this->modx->fromJSON($tmp);
         }
         $having = $this->replaceTVCondition($tmp);
         $this->query->having($having);
         $condition = array();
         foreach ($having as $k => $v) {
             if (is_array($v)) {
                 $condition[] = $k . '(' . implode(',', $v) . ')';
             } else {
                 $condition[] = $k . '=' . $v;
             }
         }
         $this->addTime('Added having condition: <b>' . implode(', ', $condition) . '</b>', microtime(true) - $time);
     }
 }
开发者ID:WhisperingTree,项目名称:blog,代码行数:55,代码来源:pdofetch.class.php


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