| @@ 736-753 (lines=18) @@ | ||
| 733 | $query->join($join[0], $join[1]); |
|
| 734 | } |
|
| 735 | static::$relJoins = []; |
|
| 736 | foreach (static::$needJoin as $rel) { |
|
| 737 | $relations = static::relations(); |
|
| 738 | if (isset($relations[$rel])) { |
|
| 739 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 740 | switch ($type) { |
|
| 741 | case 'to': |
|
| 742 | $relCol = $relations[$rel]['col']; |
|
| 743 | static::fixPrefix($relCol); |
|
| 744 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 745 | break; |
|
| 746 | case 'one': |
|
| 747 | $col = $relations[$rel]['col']; |
|
| 748 | $relations[$rel]['model']::fixPrefix($col); |
|
| 749 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 750 | break; |
|
| 751 | } |
|
| 752 | } |
|
| 753 | } |
|
| 754 | static::$needJoin = []; |
|
| 755 | ||
| 756 | if (!empty($options['limit'])) |
|
| @@ 1047-1064 (lines=18) @@ | ||
| 1044 | $query->join($join[0], $join[1]); |
|
| 1045 | } |
|
| 1046 | static::$relJoins = []; |
|
| 1047 | foreach (static::$needJoin as $rel) { |
|
| 1048 | $relations = static::relations(); |
|
| 1049 | if (isset($relations[$rel])) { |
|
| 1050 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 1051 | switch ($type) { |
|
| 1052 | case 'to': |
|
| 1053 | $relCol = $relations[$rel]['col']; |
|
| 1054 | static::fixPrefix($relCol); |
|
| 1055 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 1056 | break; |
|
| 1057 | case 'one': |
|
| 1058 | $col = $relations[$rel]['col']; |
|
| 1059 | $relations[$rel]['model']::fixPrefix($col); |
|
| 1060 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 1061 | break; |
|
| 1062 | } |
|
| 1063 | } |
|
| 1064 | } |
|
| 1065 | static::$needJoin = []; |
|
| 1066 | $cols = 'COUNT('; |
|
| 1067 | ||