@@ -1260,25 +1260,11 @@ protected function _like_statement(string $prefix = null, string $column, string
12601260 /**
12611261 * Starts a query group.
12621262 *
1263- * @param string $not (Internal use only)
1264- * @param string $type (Internal use only)
1265- *
12661263 * @return BaseBuilder
12671264 */
1268- public function groupStart (string $ not = '' , string $ type = ' AND ' )
1265+ public function groupStart ()
12691266 {
1270- $ type = $ this ->groupGetType ($ type );
1271-
1272- $ this ->QBWhereGroupStarted = true ;
1273- $ prefix = empty ($ this ->QBWhere ) ? '' : $ type ;
1274- $ where = [
1275- 'condition ' => $ prefix . $ not . str_repeat (' ' , ++ $ this ->QBWhereGroupCount ) . ' ( ' ,
1276- 'escape ' => false ,
1277- ];
1278-
1279- $ this ->QBWhere [] = $ where ;
1280-
1281- return $ this ;
1267+ return $ this ->groupStartPrepare ('' , 'AND ' , 'QBWhere ' );
12821268 }
12831269
12841270 //--------------------------------------------------------------------
@@ -1290,7 +1276,7 @@ public function groupStart(string $not = '', string $type = 'AND ')
12901276 */
12911277 public function orGroupStart ()
12921278 {
1293- return $ this ->groupStart ('' , 'OR ' );
1279+ return $ this ->groupStartPrepare ('' , 'OR ' , ' QBWhere ' );
12941280 }
12951281
12961282 //--------------------------------------------------------------------
@@ -1302,7 +1288,7 @@ public function orGroupStart()
13021288 */
13031289 public function notGroupStart ()
13041290 {
1305- return $ this ->groupStart ('NOT ' , 'AND ' );
1291+ return $ this ->groupStartPrepare ('NOT ' , 'AND ' , ' QBWhere ' );
13061292 }
13071293
13081294 //--------------------------------------------------------------------
@@ -1314,7 +1300,7 @@ public function notGroupStart()
13141300 */
13151301 public function orNotGroupStart ()
13161302 {
1317- return $ this ->groupStart ('NOT ' , 'OR ' );
1303+ return $ this ->groupStartPrepare ('NOT ' , 'OR ' , ' QBWhere ' );
13181304 }
13191305
13201306 //--------------------------------------------------------------------
@@ -1326,42 +1312,19 @@ public function orNotGroupStart()
13261312 */
13271313 public function groupEnd ()
13281314 {
1329- $ this ->QBWhereGroupStarted = false ;
1330- $ where = [
1331- 'condition ' => str_repeat (' ' , $ this ->QBWhereGroupCount -- ) . ') ' ,
1332- 'escape ' => false ,
1333- ];
1334-
1335- $ this ->QBWhere [] = $ where ;
1336-
1337- return $ this ;
1315+ return $ this ->groupEndPrepare ('QBWhere ' );
13381316 }
13391317
13401318 // --------------------------------------------------------------------
13411319
13421320 /**
13431321 * Starts a query group for HAVING clause.
13441322 *
1345- * @param string $not (Internal use only)
1346- * @param string $type (Internal use only)
1347- *
13481323 * @return BaseBuilder
13491324 */
1350- public function havingGroupStart (string $ not = '' , string $ type = ' AND ' )
1325+ public function havingGroupStart ()
13511326 {
1352- $ type = $ this ->groupGetType ($ type );
1353-
1354- $ this ->QBWhereGroupStarted = true ;
1355- $ prefix = empty ($ this ->QBHaving ) ? '' : $ type ;
1356- $ having = [
1357- 'condition ' => $ prefix . $ not . str_repeat (' ' , ++$ this ->QBWhereGroupCount ) . ' ( ' ,
1358- 'value ' => null ,
1359- 'escape ' => false ,
1360- ];
1361-
1362- $ this ->QBHaving [] = $ having ;
1363-
1364- return $ this ;
1327+ return $ this ->groupStartPrepare ('' , 'AND ' , 'QBHaving ' );
13651328 }
13661329
13671330 // --------------------------------------------------------------------
@@ -1373,7 +1336,7 @@ public function havingGroupStart(string $not = '', string $type = 'AND ')
13731336 */
13741337 public function orHavingGroupStart ()
13751338 {
1376- return $ this ->havingGroupStart ('' , 'OR ' );
1339+ return $ this ->groupStartPrepare ('' , 'OR ' , ' QBHaving ' );
13771340 }
13781341
13791342 // --------------------------------------------------------------------
@@ -1385,7 +1348,7 @@ public function orHavingGroupStart()
13851348 */
13861349 public function notHavingGroupStart ()
13871350 {
1388- return $ this ->havingGroupStart ('NOT ' , 'AND ' );
1351+ return $ this ->groupStartPrepare ('NOT ' , 'AND ' , ' QBHaving ' );
13891352 }
13901353
13911354 // --------------------------------------------------------------------
@@ -1397,7 +1360,7 @@ public function notHavingGroupStart()
13971360 */
13981361 public function orNotHavingGroupStart ()
13991362 {
1400- return $ this ->havingGroupStart ('NOT ' , 'OR ' );
1363+ return $ this ->groupStartPrepare ('NOT ' , 'OR ' , ' QBHaving ' );
14011364 }
14021365
14031366 // --------------------------------------------------------------------
@@ -1408,15 +1371,55 @@ public function orNotHavingGroupStart()
14081371 * @return BaseBuilder
14091372 */
14101373 public function havingGroupEnd ()
1374+ {
1375+ return $ this ->groupEndPrepare ('QBHaving ' );
1376+ }
1377+
1378+ //--------------------------------------------------------------------
1379+
1380+ /**
1381+ * Prepate a query group start.
1382+ *
1383+ * @param string $not
1384+ * @param string $type
1385+ * @param string $clause
1386+ *
1387+ * @return BaseBuilder
1388+ */
1389+ protected function groupStartPrepare (string $ not = '' , string $ type = 'AND ' , string $ clause = 'QBWhere ' )
1390+ {
1391+ $ type = $ this ->groupGetType ($ type );
1392+
1393+ $ this ->QBWhereGroupStarted = true ;
1394+ $ prefix = empty ($ this ->$ clause ) ? '' : $ type ;
1395+ $ where = [
1396+ 'condition ' => $ prefix . $ not . str_repeat (' ' , ++ $ this ->QBWhereGroupCount ) . ' ( ' ,
1397+ 'escape ' => false ,
1398+ ];
1399+
1400+ $ this ->{$ clause }[] = $ where ;
1401+
1402+ return $ this ;
1403+ }
1404+
1405+ //--------------------------------------------------------------------
1406+
1407+ /**
1408+ * Prepate a query group end.
1409+ *
1410+ * @param string $clause
1411+ *
1412+ * @return BaseBuilder
1413+ */
1414+ protected function groupEndPrepare (string $ clause = 'QBWhere ' )
14111415 {
14121416 $ this ->QBWhereGroupStarted = false ;
1413- $ having = [
1417+ $ where = [
14141418 'condition ' => str_repeat (' ' , $ this ->QBWhereGroupCount -- ) . ') ' ,
1415- 'value ' => null ,
14161419 'escape ' => false ,
14171420 ];
14181421
1419- $ this ->QBHaving [] = $ having ;
1422+ $ this ->{ $ clause } [] = $ where ;
14201423
14211424 return $ this ;
14221425 }
0 commit comments