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


PHP CRM_Core_Component::alterQuery方法代码示例

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


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

示例1: whereClause

 /**
  * Given a list of conditions in params generate the required.
  * where clause
  *
  * @return string
  */
 public function whereClause()
 {
     $this->_where[0] = array();
     $this->_qill[0] = array();
     $this->includeContactIds();
     if (!empty($this->_params)) {
         foreach (array_keys($this->_params) as $id) {
             if (empty($this->_params[$id][0])) {
                 continue;
             }
             // check for both id and contact_id
             if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
                 if ($this->_params[$id][1] == 'IS NULL' || $this->_params[$id][1] == 'IS NOT NULL') {
                     $this->_where[0][] = "contact_a.id {$this->_params[$id][1]}";
                 } elseif (is_array($this->_params[$id][2])) {
                     $idList = implode("','", $this->_params[$id][2]);
                     //why on earth do they put ' in the middle & not on the outside? We have to assume it's
                     //to support 'something' so lets add them conditionally to support the api (which is a tested flow
                     // so if you are looking to alter this check api test results
                     if (strpos(trim($idList), "'") > 0) {
                         $idList = "'" . $idList . "'";
                     }
                     $this->_where[0][] = "contact_a.id IN ({$idList})";
                 } else {
                     $this->_where[0][] = self::buildClause("contact_a.id", "{$this->_params[$id][1]}", "{$this->_params[$id][2]}");
                 }
             } else {
                 $this->whereClauseSingle($this->_params[$id]);
             }
         }
         CRM_Core_Component::alterQuery($this, 'where');
         CRM_Contact_BAO_Query_Hook::singleton()->alterSearchQuery($this, 'where');
     }
     if ($this->_customQuery) {
         // Added following if condition to avoid the wrong value diplay for 'myaccount' / any UF info.
         // Hope it wont affect the other part of civicrm.. if it does please remove it.
         if (!empty($this->_customQuery->_where)) {
             $this->_where = CRM_Utils_Array::crmArrayMerge($this->_where, $this->_customQuery->_where);
         }
         $this->_qill = CRM_Utils_Array::crmArrayMerge($this->_qill, $this->_customQuery->_qill);
     }
     $clauses = array();
     $andClauses = array();
     $validClauses = 0;
     if (!empty($this->_where)) {
         foreach ($this->_where as $grouping => $values) {
             if ($grouping > 0 && !empty($values)) {
                 $clauses[$grouping] = ' ( ' . implode(" {$this->_operator} ", $values) . ' ) ';
                 $validClauses++;
             }
         }
         if (!empty($this->_where[0])) {
             $andClauses[] = ' ( ' . implode(" {$this->_operator} ", $this->_where[0]) . ' ) ';
         }
         if (!empty($clauses)) {
             $andClauses[] = ' ( ' . implode(' OR ', $clauses) . ' ) ';
         }
         if ($validClauses > 1) {
             $this->_useDistinct = TRUE;
         }
     }
     return implode(' AND ', $andClauses);
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:69,代码来源:Query.php

示例2: whereClause

 /**
  * Given a list of conditions in params generate the required
  * where clause
  *
  * @return void
  * @access public
  */
 function whereClause()
 {
     $this->_where[0] = array();
     $this->_qill[0] = array();
     $config = CRM_Core_Config::singleton();
     $this->includeContactIds();
     if (!empty($this->_params)) {
         $activity = FALSE;
         foreach (array_keys($this->_params) as $id) {
             if (!CRM_Utils_Array::value(0, $this->_params[$id])) {
                 continue;
             }
             // check for both id and contact_id
             if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
                 if ($this->_params[$id][1] == 'IS NULL' || $this->_params[$id][1] == 'IS NOT NULL') {
                     $this->_where[0][] = "contact_a.id {$this->_params[$id][1]}";
                 } else {
                     $this->_where[0][] = "contact_a.id {$this->_params[$id][1]} {$this->_params[$id][2]}";
                 }
             } else {
                 $this->whereClauseSingle($this->_params[$id]);
             }
             if (substr($this->_params[$id][0], 0, 9) == 'activity_') {
                 $activity = TRUE;
             }
         }
         CRM_Core_Component::alterQuery($this, 'where');
     }
     if ($this->_customQuery) {
         // Added following if condition to avoid the wrong value diplay for 'myaccount' / any UF info.
         // Hope it wont affect the other part of civicrm.. if it does please remove it.
         if (!empty($this->_customQuery->_where)) {
             $this->_where = CRM_Utils_Array::crmArrayMerge($this->_where, $this->_customQuery->_where);
         }
         $this->_qill = CRM_Utils_Array::crmArrayMerge($this->_qill, $this->_customQuery->_qill);
     }
     $clauses = array();
     $andClauses = array();
     $validClauses = 0;
     if (!empty($this->_where)) {
         foreach ($this->_where as $grouping => $values) {
             if ($grouping > 0 && !empty($values)) {
                 $clauses[$grouping] = ' ( ' . implode(" {$this->_operator} ", $values) . ' ) ';
                 $validClauses++;
             }
         }
         if (!empty($this->_where[0])) {
             $andClauses[] = ' ( ' . implode(" {$this->_operator} ", $this->_where[0]) . ' ) ';
         }
         if (!empty($clauses)) {
             $andClauses[] = ' ( ' . implode(' OR ', $clauses) . ' ) ';
         }
         if ($validClauses > 1) {
             $this->_useDistinct = TRUE;
         }
     }
     return implode(' AND ', $andClauses);
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:65,代码来源:Query.php

示例3: whereClause

 /**
  * Given a list of conditions in params generate the required where clause.
  *
  * @param string $apiEntity
  *
  * @return string
  */
 public function whereClause($apiEntity = NULL)
 {
     $this->_where[0] = array();
     $this->_qill[0] = array();
     $this->includeContactIds();
     if (!empty($this->_params)) {
         foreach (array_keys($this->_params) as $id) {
             if (empty($this->_params[$id][0])) {
                 continue;
             }
             // check for both id and contact_id
             if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
                 $this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]);
             } else {
                 $this->whereClauseSingle($this->_params[$id], $apiEntity);
             }
         }
         CRM_Core_Component::alterQuery($this, 'where');
         CRM_Contact_BAO_Query_Hook::singleton()->alterSearchQuery($this, 'where');
     }
     if ($this->_customQuery) {
         // Added following if condition to avoid the wrong value display for 'my account' / any UF info.
         // Hope it wont affect the other part of civicrm.. if it does please remove it.
         if (!empty($this->_customQuery->_where)) {
             $this->_where = CRM_Utils_Array::crmArrayMerge($this->_where, $this->_customQuery->_where);
         }
         $this->_qill = CRM_Utils_Array::crmArrayMerge($this->_qill, $this->_customQuery->_qill);
     }
     $clauses = array();
     $andClauses = array();
     $validClauses = 0;
     if (!empty($this->_where)) {
         foreach ($this->_where as $grouping => $values) {
             if ($grouping > 0 && !empty($values)) {
                 $clauses[$grouping] = ' ( ' . implode(" {$this->_operator} ", $values) . ' ) ';
                 $validClauses++;
             }
         }
         if (!empty($this->_where[0])) {
             $andClauses[] = ' ( ' . implode(" {$this->_operator} ", $this->_where[0]) . ' ) ';
         }
         if (!empty($clauses)) {
             $andClauses[] = ' ( ' . implode(' OR ', $clauses) . ' ) ';
         }
         if ($validClauses > 1) {
             $this->_useDistinct = TRUE;
         }
     }
     return implode(' AND ', $andClauses);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:57,代码来源:Query.php


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