| @@ 767-784 (lines=18) @@ | ||
| 764 | $query->join($join[0], $join[1]); |
|
| 765 | } |
|
| 766 | static::$relJoins = []; |
|
| 767 | foreach (static::$needJoin as $rel) { |
|
| 768 | $relations = static::relations(); |
|
| 769 | if (isset($relations[$rel])) { |
|
| 770 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 771 | switch ($type) { |
|
| 772 | case 'to': |
|
| 773 | $relCol = $relations[$rel]['col']; |
|
| 774 | static::fixPrefix($relCol); |
|
| 775 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 776 | break; |
|
| 777 | case 'one': |
|
| 778 | $col = $relations[$rel]['col']; |
|
| 779 | $relations[$rel]['model']::fixPrefix($col); |
|
| 780 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 781 | break; |
|
| 782 | } |
|
| 783 | } |
|
| 784 | } |
|
| 785 | static::$needJoin = []; |
|
| 786 | ||
| 787 | if (!empty($options['limit'])) |
|
| @@ 1086-1103 (lines=18) @@ | ||
| 1083 | $query->join($join[0], $join[1]); |
|
| 1084 | } |
|
| 1085 | static::$relJoins = []; |
|
| 1086 | foreach (static::$needJoin as $rel) { |
|
| 1087 | $relations = static::relations(); |
|
| 1088 | if (isset($relations[$rel])) { |
|
| 1089 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 1090 | switch ($type) { |
|
| 1091 | case 'to': |
|
| 1092 | $relCol = $relations[$rel]['col']; |
|
| 1093 | static::fixPrefix($relCol); |
|
| 1094 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 1095 | break; |
|
| 1096 | case 'one': |
|
| 1097 | $col = $relations[$rel]['col']; |
|
| 1098 | $relations[$rel]['model']::fixPrefix($col); |
|
| 1099 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 1100 | break; |
|
| 1101 | } |
|
| 1102 | } |
|
| 1103 | } |
|
| 1104 | static::$needJoin = []; |
|
| 1105 | $cols = 'COUNT('; |
|
| 1106 | ||