@@ -156,6 +156,15 @@ class BaseBuilder
156156 */
157157 protected $ QBWhereGroupCount = 0 ;
158158
159+ /**
160+ * Ignore data that cause certain
161+ * exceptions, for example in case of
162+ * duplicate keys.
163+ *
164+ * @var boolean
165+ */
166+ protected $ QBIgnore = false ;
167+
159168 /**
160169 * A reference to the database connection.
161170 *
@@ -208,21 +217,12 @@ class BaseBuilder
208217 */
209218 protected $ canLimitWhereUpdates = true ;
210219
211- /**
212- * Ignore data that cause certain
213- * exceptions, for example in case of
214- * duplicate keys.
215- *
216- * @var bool
217- */
218- protected $ ignore = false ;
219-
220- /**
221- * Specifies which sql statements
222- * support the ignore option.
223- *
224- * @var array
225- */
220+ /**
221+ * Specifies which sql statements
222+ * support the ignore option.
223+ *
224+ * @var array
225+ */
226226 protected $ supportedIgnoreStatements = [];
227227
228228 //--------------------------------------------------------------------
@@ -271,24 +271,24 @@ public function getBinds(): array
271271 return $ this ->binds ;
272272 }
273273
274- //--------------------------------------------------------------------
274+ //--------------------------------------------------------------------
275275
276- /**
277- * Ignore
278- *
279- * Set ignore Flag for next insert,
280- * update or delete query.
281- *
282- * @param bool $ignore
283- *
284- * @return BaseBuilder
285- */
286- public function ignore (bool $ ignore = true )
287- {
288- $ this ->ignore = $ ignore ;
276+ /**
277+ * Ignore
278+ *
279+ * Set ignore Flag for next insert,
280+ * update or delete query.
281+ *
282+ * @param boolean $ignore
283+ *
284+ * @return BaseBuilder
285+ */
286+ public function ignore (bool $ ignore = true )
287+ {
288+ $ this ->QBIgnore = $ ignore ;
289289
290- return $ this ;
291- }
290+ return $ this ;
291+ }
292292
293293 //--------------------------------------------------------------------
294294
@@ -1702,8 +1702,6 @@ public function insertBatch($set = null, $escape = null, $batchSize = 100, $test
17021702 }
17031703 }
17041704
1705- $ this ->ignore = false ;
1706-
17071705 if (! $ testing )
17081706 {
17091707 $ this ->resetWrite ();
@@ -1796,8 +1794,8 @@ public function setInsertBatch($key, $value = '', $escape = null)
17961794 *
17971795 * @param boolean $reset TRUE: reset QB values; FALSE: leave QB values alone
17981796 *
1799- * @throws DatabaseException
1800- *
1797+ * @throws DatabaseException
1798+ *
18011799 * @return string
18021800 */
18031801 public function getCompiledInsert ($ reset = true )
@@ -1831,8 +1829,8 @@ public function getCompiledInsert($reset = true)
18311829 * @param array $set An associative array of insert values
18321830 * @param boolean $escape Whether to escape values and identifiers
18331831 * @param boolean $test Used when running tests
1834- *
1835- * @throws DatabaseException
1832+ *
1833+ * @throws DatabaseException
18361834 *
18371835 * @return BaseResult|Query|false
18381836 */
@@ -1854,8 +1852,6 @@ public function insert($set = null, $escape = null, $test = false)
18541852 ), array_keys ($ this ->QBSet ), array_values ($ this ->QBSet )
18551853 );
18561854
1857- $ this ->ignore = false ;
1858-
18591855 if ($ test === false )
18601856 {
18611857 $ this ->resetWrite ();
@@ -2026,8 +2022,8 @@ public function getCompiledUpdate($reset = true)
20262022 * @param mixed $where
20272023 * @param integer $limit
20282024 * @param boolean $test Are we testing the code?
2029- *
2030- * @throws DatabaseException
2025+ *
2026+ * @throws DatabaseException
20312027 *
20322028 * @return boolean TRUE on success, FALSE on failure
20332029 */
@@ -2060,8 +2056,6 @@ public function update($set = null, $where = null, int $limit = null, $test = fa
20602056
20612057 $ sql = $ this ->_update ($ this ->QBFrom [0 ], $ this ->QBSet );
20622058
2063- $ this ->ignore = false ;
2064-
20652059 if (! $ test )
20662060 {
20672061 $ this ->resetWrite ();
@@ -2094,7 +2088,7 @@ public function update($set = null, $where = null, int $limit = null, $test = fa
20942088 */
20952089 protected function _update ($ table , $ values )
20962090 {
2097- $ valStr = [];
2091+ $ valStr = [];
20982092
20992093 foreach ($ values as $ key => $ val )
21002094 {
@@ -2209,8 +2203,6 @@ public function updateBatch($set = null, $index = null, $batchSize = 100, $retur
22092203 $ this ->QBWhere = [];
22102204 }
22112205
2212- $ this ->ignore = false ;
2213-
22142206 $ this ->resetWrite ();
22152207
22162208 return $ returnSQL ? $ savedSQL : $ affected_rows ;
@@ -2231,7 +2223,7 @@ public function updateBatch($set = null, $index = null, $batchSize = 100, $retur
22312223 */
22322224 protected function _updateBatch ($ table , $ values , $ index )
22332225 {
2234- $ ids = [];
2226+ $ ids = [];
22352227 $ final = [];
22362228
22372229 foreach ($ values as $ key => $ val )
@@ -2326,8 +2318,6 @@ public function emptyTable($test = false)
23262318
23272319 $ sql = $ this ->_delete ($ table );
23282320
2329- $ this ->ignore = false ;
2330-
23312321 if ($ test )
23322322 {
23332323 return $ sql ;
@@ -2444,8 +2434,6 @@ public function delete($where = '', $limit = null, $reset_data = true, $returnSQ
24442434
24452435 $ sql = $ this ->_delete ($ table );
24462436
2447- $ this ->ignore = false ;
2448-
24492437 if (! empty ($ limit ))
24502438 {
24512439 $ this ->QBLimit = $ limit ;
@@ -2635,31 +2623,31 @@ protected function compileSelect($select_override = false)
26352623 return $ sql ;
26362624 }
26372625
2638- //--------------------------------------------------------------------
2626+ //--------------------------------------------------------------------
26392627
2640- /**
2641- * Compile Ignore Statement
2642- *
2643- * Checks if the ignore option is supported by
2644- * the Database Driver for the specific statement.
2645- *
2646- * @param string $statement
2647- *
2648- * @return string
2649- */
2650- protected function compileIgnore (string $ statement )
2651- {
2652- $ sql = '' ;
2628+ /**
2629+ * Compile Ignore Statement
2630+ *
2631+ * Checks if the ignore option is supported by
2632+ * the Database Driver for the specific statement.
2633+ *
2634+ * @param string $statement
2635+ *
2636+ * @return string
2637+ */
2638+ public function compileIgnore (string $ statement )
2639+ {
2640+ $ sql = '' ;
26532641
2654- if (
2655- $ this ->ignore &&
2656- isset ( $ this -> supportedIgnoreStatements [ $ statement ] )
2657- ) {
2658- $ sql = trim ($ this ->supportedIgnoreStatements [$ statement ]). ' ' ;
2659- }
2642+ if ( $ this -> QBIgnore &&
2643+ isset ( $ this ->supportedIgnoreStatements [ $ statement ])
2644+ )
2645+ {
2646+ $ sql = trim ($ this ->supportedIgnoreStatements [$ statement ]) . ' ' ;
2647+ }
26602648
2661- return $ sql ;
2662- }
2649+ return $ sql ;
2650+ }
26632651
26642652 //--------------------------------------------------------------------
26652653
@@ -2983,6 +2971,7 @@ protected function resetWrite()
29832971 'QBOrderBy ' => [],
29842972 'QBKeys ' => [],
29852973 'QBLimit ' => false ,
2974+ 'QBIgnore ' => false ,
29862975 ]);
29872976 }
29882977
0 commit comments