dev/core#183 Event Price Set Custom Search to using CRM_Utils_SQL_TempTable interface
authorSeamus Lee <seamuslee001@gmail.com>
Mon, 11 Nov 2019 20:42:20 +0000 (07:42 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 21 Nov 2019 06:04:33 +0000 (17:04 +1100)
CRM/Contact/Form/Search/Custom/PriceSet.php

index 0c97298c6ef469000143b3e7141b773d50f0cbc0..a927dc5b0bc587ab8859cb837c623a74bbe1f0fd 100644 (file)
@@ -55,11 +55,7 @@ class CRM_Contact_Form_Search_Custom_PriceSet extends CRM_Contact_Form_Search_Cu
   }
 
   public function buildTempTable() {
-    $randomNum = md5(uniqid());
-    $this->_tableName = "civicrm_temp_custom_{$randomNum}";
-    $sql = "
-CREATE TEMPORARY TABLE {$this->_tableName} (
-  id int unsigned NOT NULL AUTO_INCREMENT,
+    $sql = "id int unsigned NOT NULL AUTO_INCREMENT,
   contact_id int unsigned NOT NULL,
   participant_id int unsigned NOT NULL,
 ";
@@ -76,12 +72,10 @@ CREATE TEMPORARY TABLE {$this->_tableName} (
     }
 
     $sql .= "
-PRIMARY KEY ( id ),
-UNIQUE INDEX unique_participant_id ( participant_id )
-) ENGINE=HEAP
-";
+      PRIMARY KEY ( id ),
+      UNIQUE INDEX unique_participant_id ( participant_id )";
 
-    CRM_Core_DAO::executeQuery($sql);
+    $this->_tableName = CRM_Utils_SQL_TempTable::build()->setCategory('priceset')->setMemory()->createWithColumns($sql)->getName();
   }
 
   public function fillTable() {