From: Tim Otten Date: Fri, 19 May 2023 07:10:09 +0000 (-0700) Subject: SqlData - Allow INSERT IGNORE X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=795b5a297cc31f7f70d3d29d85aab45697920fef;p=civicrm-core.git SqlData - Allow INSERT IGNORE --- diff --git a/CRM/Core/CodeGen/SqlData.php b/CRM/Core/CodeGen/SqlData.php index 058a005ace..6ad8ff7f01 100644 --- a/CRM/Core/CodeGen/SqlData.php +++ b/CRM/Core/CodeGen/SqlData.php @@ -11,9 +11,16 @@ class CRM_Core_CodeGen_SqlData extends CRM_Core_CodeGen_AbstractSqlData { */ protected $table; - public static function create(string $table): CRM_Core_CodeGen_SqlData { + /** + * @var string + * Ex: 'INSERT INTO' + */ + protected $verb; + + public static function create(string $table, string $verb = 'INSERT INTO'): CRM_Core_CodeGen_SqlData { $sqlData = new static(); $sqlData->table = $table; + $sqlData->verb = $verb; return $sqlData; } @@ -29,7 +36,7 @@ class CRM_Core_CodeGen_SqlData extends CRM_Core_CodeGen_AbstractSqlData { $result = ''; $rows = $this->toArray(); if ($rows) { - $result .= CRM_Utils_SQL_Insert::into($this->table) + $result .= CRM_Utils_SQL_Insert::into($this->table, $this->verb) ->allowLiterals() ->rows($rows) ->toSQL() . ";\n";