| @@ 1281-1298 (lines=18) @@ | ||
| 1278 | $query->join($join[0], $join[1]); |
|
| 1279 | } |
|
| 1280 | static::$relJoins = []; |
|
| 1281 | foreach (static::$needJoin as $rel) { |
|
| 1282 | $relations = static::relations(); |
|
| 1283 | if (isset($relations[$rel])) { |
|
| 1284 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 1285 | switch ($type) { |
|
| 1286 | case 'to': |
|
| 1287 | $relCol = $relations[$rel]['col']; |
|
| 1288 | static::fixPrefix($relCol); |
|
| 1289 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 1290 | break; |
|
| 1291 | case 'one': |
|
| 1292 | $col = $relations[$rel]['col']; |
|
| 1293 | $relations[$rel]['model']::fixPrefix($col); |
|
| 1294 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 1295 | break; |
|
| 1296 | } |
|
| 1297 | } |
|
| 1298 | } |
|
| 1299 | static::$needJoin = []; |
|
| 1300 | $cols = 'COUNT('; |
|
| 1301 | ||
| @@ 939-956 (lines=18) @@ | ||
| 936 | $query->join($join[0], $join[1]); |
|
| 937 | } |
|
| 938 | static::$relJoins = []; |
|
| 939 | foreach (static::$needJoin as $rel) { |
|
| 940 | $relations = static::relations(); |
|
| 941 | if (isset($relations[$rel])) { |
|
| 942 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 943 | switch ($type) { |
|
| 944 | case 'to': |
|
| 945 | $relCol = $relations[$rel]['col']; |
|
| 946 | static::fixPrefix($relCol); |
|
| 947 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 948 | break; |
|
| 949 | case 'one': |
|
| 950 | $col = $relations[$rel]['col']; |
|
| 951 | $relations[$rel]['model']::fixPrefix($col); |
|
| 952 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 953 | break; |
|
| 954 | } |
|
| 955 | } |
|
| 956 | } |
|
| 957 | static::$needJoin = []; |
|
| 958 | ||
| 959 | if (!empty($options['limit'])) { |
|