@@ -416,15 +416,15 @@ public function getGroupBy() : string
416
416
}
417
417
418
418
$ comma = '' ;
419
- $ retVal = ' GROUP BY ' ;
419
+ $ retVal = "\n GROUP BY " ;
420
420
$ addRollup = 0 ;
421
421
422
422
foreach ($ this ->groupBys as $ field => $ rollup )
423
423
{
424
424
$ parts = \explode ('. ' , $ field );
425
425
$ field = \implode ('`.` ' , $ parts );
426
426
$ retVal .= "{$ comma } ` {$ field }` " ;
427
- $ comma = ' , ' ;
427
+ $ comma = " , \n" ;
428
428
429
429
$ addRollup |= (int )$ rollup ;
430
430
}
@@ -453,7 +453,7 @@ public function getHaving(array &$input) : string
453
453
454
454
$ input = \array_merge ($ input , $ this ->havingCondition ->getInput ());
455
455
456
- return ' HAVING ' . $ this ->havingCondition ;
456
+ return "\n HAVING " . $ this ->havingCondition ;
457
457
}
458
458
459
459
public function getHavingCondition () : \PHPFUI \ORM \Condition
@@ -495,7 +495,7 @@ public function getLimitClause() : string
495
495
// could just be a string, return it
496
496
if ($ this ->limit && ! $ this ->offset && null === $ this ->page )
497
497
{
498
- return ' LIMIT ' . $ this ->limit ;
498
+ return "\n LIMIT { $ this ->limit }" ;
499
499
}
500
500
501
501
if (! $ this ->limit )
@@ -515,7 +515,7 @@ public function getLimitClause() : string
515
515
}
516
516
$ this ->offset = $ offset ;
517
517
518
- return " LIMIT {$ offset }, {$ this ->limit }" ;
518
+ return "\n LIMIT {$ offset }, {$ this ->limit }" ;
519
519
}
520
520
521
521
public function getOffset () : ?int
@@ -534,7 +534,7 @@ public function getOrderBy() : string
534
534
}
535
535
536
536
$ comma = '' ;
537
- $ retVal = ' ORDER BY ' ;
537
+ $ retVal = "\n ORDER BY " ;
538
538
539
539
foreach ($ this ->orderBys as $ field => $ direction )
540
540
{
@@ -607,7 +607,7 @@ public function getSelect() : string
607
607
608
608
$ columns = [];
609
609
// make explicit column names for joined tables since we don't have explicit selects
610
- $ sql = "` {$ this ->instance ->getTableName ()}`.* " ;
610
+ $ sql = "\n ` {$ this ->instance ->getTableName ()}`.* " ;
611
611
// set column names from explicit select
612
612
foreach ($ this ->getFields () as $ field => $ data )
613
613
{
@@ -625,11 +625,11 @@ public function getSelect() : string
625
625
{
626
626
if (isset ($ columns [$ field ]))
627
627
{
628
- $ sql .= ",` {$ tableName }`.` {$ field }` as ` {$ tableName }_ {$ field }` " ;
628
+ $ sql .= ", \n ` {$ tableName }`.` {$ field }` as ` {$ tableName }_ {$ field }` " ;
629
629
}
630
630
else
631
631
{
632
- $ sql .= ",` {$ tableName }`.` {$ field }` " ;
632
+ $ sql .= ", \n ` {$ tableName }`.` {$ field }` " ;
633
633
$ columns [$ field ] = true ;
634
634
}
635
635
}
@@ -639,7 +639,7 @@ public function getSelect() : string
639
639
{
640
640
return $ sql ;
641
641
}
642
- $ comma = ' , ' ;
642
+ $ comma = " , \n" ;
643
643
}
644
644
645
645
foreach ($ this ->selects as $ field => $ as )
@@ -650,7 +650,7 @@ public function getSelect() : string
650
650
{
651
651
$ sql .= ' as ` ' . $ as . '` ' ;
652
652
}
653
- $ comma = ' , ' ;
653
+ $ comma = " , \n" ;
654
654
}
655
655
$ sql = \str_replace ('`*` ' , '* ' , $ sql );
656
656
@@ -672,7 +672,7 @@ public function getSQL(array &$input, bool $limited = true) : string
672
672
$ having = $ this ->getHaving ($ input );
673
673
$ orderBy = $ this ->getOrderBy ();
674
674
$ limit = $ this ->getLimitClause ();
675
- $ sql = "SELECT {$ this ->distinct } {$ select } FROM ` {$ table }` " . $ joins . $ where . $ groupBy . $ having ;
675
+ $ sql = "SELECT {$ this ->distinct } {$ select }\n FROM ` {$ table }` " . $ joins . $ where . $ groupBy . $ having ;
676
676
677
677
if ($ this ->unions )
678
678
{
@@ -719,7 +719,7 @@ public function getWhere(array &$input) : string
719
719
720
720
$ input = \array_merge ($ input , $ this ->whereCondition ->getInput ());
721
721
722
- return ' WHERE ' . $ this ->whereCondition ;
722
+ return "\n WHERE " . $ this ->whereCondition ;
723
723
}
724
724
725
725
public function getWhereCondition () : \PHPFUI \ORM \Condition
@@ -752,7 +752,7 @@ public function insert(array $records, string $ignore = '') : bool
752
752
foreach ($ fields as $ fieldName )
753
753
{
754
754
$ sql .= "{$ comma }` {$ fieldName }` " ;
755
- $ comma = ' , ' ;
755
+ $ comma = " , \n" ;
756
756
}
757
757
758
758
$ sql .= ') values ' ;
@@ -773,7 +773,7 @@ public function insert(array $records, string $ignore = '') : bool
773
773
foreach ($ fields as $ fieldName )
774
774
{
775
775
$ sql .= $ comma . '? ' ;
776
- $ comma = ' , ' ;
776
+ $ comma = " , \n" ;
777
777
$ input [] = $ record [$ fieldName ];
778
778
}
779
779
$ comma = '),( ' ;
@@ -965,7 +965,7 @@ public function update(array $variables) : static
965
965
{
966
966
$ this ->lastSql .= "{$ comma } ` {$ field }`=? " ;
967
967
$ this ->lastInput [] = $ value ;
968
- $ comma = ' , ' ;
968
+ $ comma = " , \n" ;
969
969
}
970
970
971
971
$ where = $ this ->getWhere ($ this ->lastInput );
@@ -1062,7 +1062,7 @@ private function getJoins(array &$input) : string
1062
1062
$ onCondition = $ joinInfo [1 ];
1063
1063
$ joinType = $ joinInfo [2 ];
1064
1064
$ input = \array_merge ($ input , $ onCondition ->getInput ());
1065
- $ joins .= " {$ joinType } JOIN ` {$ joinTableName }` {$ as } ON {$ onCondition }" ;
1065
+ $ joins .= "\n {$ joinType } JOIN ` {$ joinTableName }` {$ as } ON {$ onCondition }" ;
1066
1066
}
1067
1067
1068
1068
return $ joins ;
0 commit comments