@@ -718,17 +718,21 @@ discard block |
||
718 | 718 | if (!$query) { |
719 | 719 | return []; |
720 | 720 | } |
721 | - if (!empty($options['where'])) |
|
722 | - $query->where($options['where']); |
|
721 | + if (!empty($options['where'])) { |
|
722 | + $query->where($options['where']); |
|
723 | + } |
|
723 | 724 | if (!empty($options['group'])) { |
724 | 725 | $query->group($options['group']); |
725 | 726 | } |
726 | - if (!empty($options['order'])) |
|
727 | - $query->order($options['order']); |
|
728 | - if (!empty($options['join'])) |
|
729 | - $query->join($options['join']); |
|
730 | - if (!empty($options['distinct'])) |
|
731 | - $query->distinct = $options['distinct']; |
|
727 | + if (!empty($options['order'])) { |
|
728 | + $query->order($options['order']); |
|
729 | + } |
|
730 | + if (!empty($options['join'])) { |
|
731 | + $query->join($options['join']); |
|
732 | + } |
|
733 | + if (!empty($options['distinct'])) { |
|
734 | + $query->distinct = $options['distinct']; |
|
735 | + } |
|
732 | 736 | |
733 | 737 | foreach (static::$relJoins as $join) { |
734 | 738 | $query->join($join[0], $join[1]); |
@@ -754,14 +758,14 @@ discard block |
||
754 | 758 | } |
755 | 759 | static::$needJoin = []; |
756 | 760 | |
757 | - if (!empty($options['limit'])) |
|
758 | - $limit = (int) $options['limit']; |
|
759 | - else { |
|
761 | + if (!empty($options['limit'])) { |
|
762 | + $limit = (int) $options['limit']; |
|
763 | + } else { |
|
760 | 764 | $limit = 0; |
761 | 765 | } |
762 | - if (!empty($options['start'])) |
|
763 | - $start = (int) $options['start']; |
|
764 | - else { |
|
766 | + if (!empty($options['start'])) { |
|
767 | + $start = (int) $options['start']; |
|
768 | + } else { |
|
765 | 769 | $start = 0; |
766 | 770 | } |
767 | 771 | if ($limit || $start) { |
@@ -781,8 +785,7 @@ discard block |
||
781 | 785 | if ($exc->getCode() == '42S02') { |
782 | 786 | static::createTable(); |
783 | 787 | $result = $query->query($queryArr); |
784 | - } |
|
785 | - else { |
|
788 | + } else { |
|
786 | 789 | throw $exc; |
787 | 790 | } |
788 | 791 | |
@@ -1027,21 +1030,23 @@ discard block |
||
1027 | 1030 | if (!empty($options['where'])) { |
1028 | 1031 | static::fixPrefix($options['where'], 'first'); |
1029 | 1032 | } |
1030 | - if (!empty($options['where'])) |
|
1031 | - $query->where($options['where']); |
|
1032 | - if (!empty($options['join'])) |
|
1033 | - $query->join($options['join']); |
|
1033 | + if (!empty($options['where'])) { |
|
1034 | + $query->where($options['where']); |
|
1035 | + } |
|
1036 | + if (!empty($options['join'])) { |
|
1037 | + $query->join($options['join']); |
|
1038 | + } |
|
1034 | 1039 | if (!empty($options['order'])) { |
1035 | 1040 | $query->order($options['order']); |
1036 | 1041 | } |
1037 | - if (!empty($options['limit'])) |
|
1038 | - $limit = (int) $options['limit']; |
|
1039 | - else { |
|
1042 | + if (!empty($options['limit'])) { |
|
1043 | + $limit = (int) $options['limit']; |
|
1044 | + } else { |
|
1040 | 1045 | $limit = 0; |
1041 | 1046 | } |
1042 | - if (!empty($options['start'])) |
|
1043 | - $start = (int) $options['start']; |
|
1044 | - else { |
|
1047 | + if (!empty($options['start'])) { |
|
1048 | + $start = (int) $options['start']; |
|
1049 | + } else { |
|
1045 | 1050 | $start = 0; |
1046 | 1051 | } |
1047 | 1052 | if ($limit || $start) { |
@@ -1119,8 +1124,9 @@ discard block |
||
1119 | 1124 | |
1120 | 1125 | $values = []; |
1121 | 1126 | foreach ($cols as $col => $param) { |
1122 | - if (isset($params[$col])) |
|
1123 | - $values[$col] = $params[$col]; |
|
1127 | + if (isset($params[$col])) { |
|
1128 | + $values[$col] = $params[$col]; |
|
1129 | + } |
|
1124 | 1130 | } |
1125 | 1131 | if (empty($values)) { |
1126 | 1132 | return false; |
@@ -1303,8 +1309,9 @@ discard block |
||
1303 | 1309 | $values = []; |
1304 | 1310 | |
1305 | 1311 | foreach ($this->cols() as $col => $param) { |
1306 | - if (isset($this->_params[$col])) |
|
1307 | - $values[$col] = $this->_params[$col]; |
|
1312 | + if (isset($this->_params[$col])) { |
|
1313 | + $values[$col] = $this->_params[$col]; |
|
1314 | + } |
|
1308 | 1315 | } |
1309 | 1316 | if (empty($values) && empty($options['empty'])) { |
1310 | 1317 | return false; |
@@ -1464,8 +1471,9 @@ discard block |
||
1464 | 1471 | { |
1465 | 1472 | |
1466 | 1473 | foreach (static::relations() as $relName => $rel) { |
1467 | - if ($rel['col'] == $col) |
|
1468 | - return $relName; |
|
1474 | + if ($rel['col'] == $col) { |
|
1475 | + return $relName; |
|
1476 | + } |
|
1469 | 1477 | } |
1470 | 1478 | return NULL; |
1471 | 1479 | } |