const CATEGORY_REGEXP = ';^[a-zA-Z0-9]+$;';
const ID_LENGTH = 37; // MAX{64} - CATEGORY_LENGTH{12} - CONST_LENGHTH{15} = 37
const ID_REGEXP = ';^[a-zA-Z0-9_]+$;';
+ const INNODB = 'ENGINE=InnoDB';
+ const MEMORY = 'ENGINE=MEMORY';
/**
* @var bool
protected $autodrop;
+ protected $memory;
+
/**
* @return CRM_Utils_SQL_TempTable
*/
// I suspect it would be better to just say utf8=true, but a lot of existing queries don't do the utf8 bit.
$t->utf8 = CRM_Utils_Constant::value('CIVICRM_TEMP_FORCE_UTF8', FALSE);
$t->autodrop = FALSE;
+ $t->memory = FALSE;
return $t;
}
* @return CRM_Utils_SQL_TempTable
*/
public function createWithQuery($selectQuery) {
- $sql = sprintf('%s %s AS %s',
+ $sql = sprintf('%s %s %s AS %s',
$this->toSQL('CREATE'),
+ $this->memory ? self::MEMORY : self::INNODB,
$this->utf8 ? self::UTF8 : '',
($selectQuery instanceof CRM_Utils_SQL_Select ? $selectQuery->toSQL() : $selectQuery)
);
* @return CRM_Utils_SQL_TempTable
*/
public function createWithColumns($columns) {
- $sql = sprintf('%s (%s) %s',
+ $sql = sprintf('%s (%s) %s %s',
$this->toSQL('CREATE'),
$columns,
+ $this->memory ? self::MEMORY : self::INNODB,
$this->utf8 ? self::UTF8 : ''
);
CRM_Core_DAO::executeQuery($sql, array(), TRUE, NULL, TRUE, FALSE);
return $this->durable;
}
+ /**
+ * @return bool
+ */
+ public function isMemory() {
+ return $this->memory;
+ }
+
/**
* @return bool
*/
return $this;
}
+ /**
+ * Set table engine to MEMORY.
+ *
+ * @param bool $value
+ *
+ * @return $this
+ */
+ public function setMemory($value = TRUE) {
+ $this->memory = $value;
+ return $this;
+ }
+
/**
* Set table collation to UTF8.
*