From: eileen Date: Tue, 5 Mar 2019 00:05:16 +0000 (+1300) Subject: Call getSearchSQLParts to get the desired part instead of sql wrangling X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=0e7133bee4e93e484f66888850fe7c3ce874f65d;p=civicrm-core.git Call getSearchSQLParts to get the desired part instead of sql wrangling --- diff --git a/CRM/Campaign/Selector/Search.php b/CRM/Campaign/Selector/Search.php index ec046e6ab3..f3315a0b00 100644 --- a/CRM/Campaign/Selector/Search.php +++ b/CRM/Campaign/Selector/Search.php @@ -273,17 +273,17 @@ class CRM_Campaign_Selector_Search extends CRM_Core_Selector_Base implements CRM $cacheKey = "civicrm search {$this->_key}"; Civi::service('prevnext')->deleteItem(NULL, $cacheKey, 'civicrm_contact'); - $sql = $this->_query->getSearchSQL(0, 0, $sort, + $sql = $this->_query->getSearchSQLParts(0, 0, $sort, FALSE, FALSE, FALSE, FALSE, $this->_campaignWhereClause, NULL, $this->_campaignFromClause ); - list($select, $from) = explode(' FROM ', $sql); + $selectSQL = " SELECT %1, contact_a.id, contact_a.display_name -FROM {$from} +FROM {$sql['from']} "; try { diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index e61291cd86..5bad91bed0 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -555,15 +555,12 @@ WHERE id IN ( $groupIDs ) ); $query->_useDistinct = FALSE; $query->_useGroupBy = FALSE; - $searchSQL - = $query->searchQuery( + $sqlParts = $query->getSearchSQLParts( 0, 0, NULL, FALSE, FALSE, - FALSE, TRUE, - TRUE, - NULL, NULL, NULL, - TRUE + FALSE, TRUE ); + $searchSQL = "{$sqlParts['select']} {$sqlParts['from']} {$sqlParts['where']} {$sqlParts['having']} {$sqlParts['group_by']}"; } $groupID = CRM_Utils_Type::escape($groupID, 'Integer'); $sql = $searchSQL . " AND contact_a.id NOT IN (