@@ -208,6 +208,14 @@ class BaseBuilder
208208 */
209209 protected $ canLimitWhereUpdates = true ;
210210
211+ /**
212+ * Ignore errors on insert statements
213+ * for example for duplicate keys.
214+ *
215+ * @var bool
216+ */
217+ protected $ insertIgnore = false ;
218+
211219 //--------------------------------------------------------------------
212220
213221 /**
@@ -254,6 +262,22 @@ public function getBinds(): array
254262 return $ this ->binds ;
255263 }
256264
265+ //--------------------------------------------------------------------
266+
267+ /**
268+ * Ignore
269+ *
270+ * Set ignore Flag for next insert query.
271+ *
272+ * @return BaseBuilder
273+ */
274+ public function ignore ()
275+ {
276+ $ this ->insertIgnore = true ;
277+
278+ return $ this ;
279+ }
280+
257281 //--------------------------------------------------------------------
258282
259283 /**
@@ -1666,6 +1690,8 @@ public function insertBatch($set = null, $escape = null, $batchSize = 100, $test
16661690 }
16671691 }
16681692
1693+ $ this ->insertIgnore = false ;
1694+
16691695 if (! $ testing )
16701696 {
16711697 $ this ->resetWrite ();
@@ -1758,6 +1784,8 @@ public function setInsertBatch($key, $value = '', $escape = null)
17581784 *
17591785 * @param boolean $reset TRUE: reset QB values; FALSE: leave QB values alone
17601786 *
1787+ * @throws DatabaseException
1788+ *
17611789 * @return string
17621790 */
17631791 public function getCompiledInsert ($ reset = true )
@@ -1791,6 +1819,8 @@ public function getCompiledInsert($reset = true)
17911819 * @param array $set An associative array of insert values
17921820 * @param boolean $escape Whether to escape values and identifiers
17931821 * @param boolean $test Used when running tests
1822+ *
1823+ * @throws DatabaseException
17941824 *
17951825 * @return BaseResult|Query|false
17961826 */
@@ -1812,6 +1842,8 @@ public function insert($set = null, $escape = null, $test = false)
18121842 ), array_keys ($ this ->QBSet ), array_values ($ this ->QBSet )
18131843 );
18141844
1845+ $ this ->insertIgnore = false ;
1846+
18151847 if ($ test === false )
18161848 {
18171849 $ this ->resetWrite ();
0 commit comments