| @@ 737-754 (lines=18) @@ | ||
| 734 | $query->join($join[0], $join[1]); |
|
| 735 | } |
|
| 736 | static::$relJoins = []; |
|
| 737 | foreach (static::$needJoin as $rel) { |
|
| 738 | $relations = static::relations(); |
|
| 739 | if (isset($relations[$rel])) { |
|
| 740 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 741 | switch ($type) { |
|
| 742 | case 'to': |
|
| 743 | $relCol = $relations[$rel]['col']; |
|
| 744 | static::fixPrefix($relCol); |
|
| 745 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 746 | break; |
|
| 747 | case 'one': |
|
| 748 | $col = $relations[$rel]['col']; |
|
| 749 | $relations[$rel]['model']::fixPrefix($col); |
|
| 750 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 751 | break; |
|
| 752 | } |
|
| 753 | } |
|
| 754 | } |
|
| 755 | static::$needJoin = []; |
|
| 756 | ||
| 757 | if (!empty($options['limit'])) |
|
| @@ 1058-1075 (lines=18) @@ | ||
| 1055 | $query->join($join[0], $join[1]); |
|
| 1056 | } |
|
| 1057 | static::$relJoins = []; |
|
| 1058 | foreach (static::$needJoin as $rel) { |
|
| 1059 | $relations = static::relations(); |
|
| 1060 | if (isset($relations[$rel])) { |
|
| 1061 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 1062 | switch ($type) { |
|
| 1063 | case 'to': |
|
| 1064 | $relCol = $relations[$rel]['col']; |
|
| 1065 | static::fixPrefix($relCol); |
|
| 1066 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 1067 | break; |
|
| 1068 | case 'one': |
|
| 1069 | $col = $relations[$rel]['col']; |
|
| 1070 | $relations[$rel]['model']::fixPrefix($col); |
|
| 1071 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 1072 | break; |
|
| 1073 | } |
|
| 1074 | } |
|
| 1075 | } |
|
| 1076 | static::$needJoin = []; |
|
| 1077 | $cols = 'COUNT('; |
|
| 1078 | ||