Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#183 Finish converting contrib sybnt custom search to using t… #15820

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
dev/core#183 Finish converting contrib sybnt custom search to using t…
…em table class
  • Loading branch information
seamuslee001 committed Nov 13, 2019
commit 6b14f61dc38c710750f659651147f2cf45514703
14 changes: 7 additions & 7 deletions CRM/Contact/Form/Search/Custom/ContribSYBNT.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function from() {
!empty($this->exclude_end_date) ||
!empty($this->is_first_amount)
) {
$from .= " LEFT JOIN XG_CustomSearch_SYBNT xg ON xg.contact_id = contact_a.id ";
$from .= " LEFT JOIN {$this->_xgTableName} xg ON xg.contact_id = contact_a.id ";
}

return $from;
Expand Down Expand Up @@ -269,11 +269,11 @@ public function where($includeContactIDs = FALSE) {
) {

// first create temp table to store contact ids
$sql = "DROP TEMPORARY TABLE IF EXISTS XG_CustomSearch_SYBNT";
CRM_Core_DAO::executeQuery($sql);

$sql = "CREATE TEMPORARY TABLE XG_CustomSearch_SYBNT ( contact_id int primary key) ENGINE=HEAP";
$this->_xgTable = CRM_Utils_SQL_TempTable::build()->setMemory();
$this->_xgTableName = $this->_xgTable->getName();
$sql = "DROP TEMPORARY TABLE IF EXISTS {$this->_xgTableName}";
CRM_Core_DAO::executeQuery($sql);
$this->_xgTable->createWithColumns('contact_id int primary key');

$excludeClauses = [];
if ($this->exclude_start_date) {
Expand Down Expand Up @@ -306,7 +306,7 @@ public function where($includeContactIDs = FALSE) {
if ($excludeClause || $havingClause) {
// Run subquery
$query = "
REPLACE INTO XG_CustomSearch_SYBNT
REPLACE INTO {$this->_xgTableName}
SELECT DISTINCT contact_id AS contact_id
FROM civicrm_contribution c
WHERE c.is_test = 0
Expand All @@ -321,7 +321,7 @@ public function where($includeContactIDs = FALSE) {
// now ensure we dont consider donors that are not first time
if ($this->is_first_amount) {
$query = "
REPLACE INTO XG_CustomSearch_SYBNT
REPLACE INTO {$this->_xgTableName}
SELECT DISTINCT contact_id AS contact_id
FROM civicrm_contribution c
WHERE c.is_test = 0
Expand Down