| @@ 979-996 (lines=18) @@ | ||
| 976 | $query->join($join[0], $join[1]); |
|
| 977 | } |
|
| 978 | static::$relJoins = []; |
|
| 979 | foreach (static::$needJoin as $rel) { |
|
| 980 | $relations = static::relations(); |
|
| 981 | if (isset($relations[$rel])) { |
|
| 982 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 983 | switch ($type) { |
|
| 984 | case 'to': |
|
| 985 | $relCol = $relations[$rel]['col']; |
|
| 986 | static::fixPrefix($relCol); |
|
| 987 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 988 | break; |
|
| 989 | case 'one': |
|
| 990 | $col = $relations[$rel]['col']; |
|
| 991 | $relations[$rel]['model']::fixPrefix($col); |
|
| 992 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 993 | break; |
|
| 994 | } |
|
| 995 | } |
|
| 996 | } |
|
| 997 | static::$needJoin = []; |
|
| 998 | ||
| 999 | if (!empty($options['limit'])) { |
|
| @@ 1321-1338 (lines=18) @@ | ||
| 1318 | $query->join($join[0], $join[1]); |
|
| 1319 | } |
|
| 1320 | static::$relJoins = []; |
|
| 1321 | foreach (static::$needJoin as $rel) { |
|
| 1322 | $relations = static::relations(); |
|
| 1323 | if (isset($relations[$rel])) { |
|
| 1324 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 1325 | switch ($type) { |
|
| 1326 | case 'to': |
|
| 1327 | $relCol = $relations[$rel]['col']; |
|
| 1328 | static::fixPrefix($relCol); |
|
| 1329 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 1330 | break; |
|
| 1331 | case 'one': |
|
| 1332 | $col = $relations[$rel]['col']; |
|
| 1333 | $relations[$rel]['model']::fixPrefix($col); |
|
| 1334 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 1335 | break; |
|
| 1336 | } |
|
| 1337 | } |
|
| 1338 | } |
|
| 1339 | static::$needJoin = []; |
|
| 1340 | $cols = 'COUNT('; |
|
| 1341 | ||