當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。