| @@ 936-953 (lines=18) @@ | ||
| 933 | $query->join($join[0], $join[1]); |
|
| 934 | } |
|
| 935 | static::$relJoins = []; |
|
| 936 | foreach (static::$needJoin as $rel) { |
|
| 937 | $relations = static::relations(); |
|
| 938 | if (isset($relations[$rel])) { |
|
| 939 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 940 | switch ($type) { |
|
| 941 | case 'to': |
|
| 942 | $relCol = $relations[$rel]['col']; |
|
| 943 | static::fixPrefix($relCol); |
|
| 944 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 945 | break; |
|
| 946 | case 'one': |
|
| 947 | $col = $relations[$rel]['col']; |
|
| 948 | $relations[$rel]['model']::fixPrefix($col); |
|
| 949 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 950 | break; |
|
| 951 | } |
|
| 952 | } |
|
| 953 | } |
|
| 954 | static::$needJoin = []; |
|
| 955 | ||
| 956 | if (!empty($options['limit'])) { |
|
| @@ 1268-1285 (lines=18) @@ | ||
| 1265 | $query->join($join[0], $join[1]); |
|
| 1266 | } |
|
| 1267 | static::$relJoins = []; |
|
| 1268 | foreach (static::$needJoin as $rel) { |
|
| 1269 | $relations = static::relations(); |
|
| 1270 | if (isset($relations[$rel])) { |
|
| 1271 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 1272 | switch ($type) { |
|
| 1273 | case 'to': |
|
| 1274 | $relCol = $relations[$rel]['col']; |
|
| 1275 | static::fixPrefix($relCol); |
|
| 1276 | $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 1277 | break; |
|
| 1278 | case 'one': |
|
| 1279 | $col = $relations[$rel]['col']; |
|
| 1280 | $relations[$rel]['model']::fixPrefix($col); |
|
| 1281 | $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 1282 | break; |
|
| 1283 | } |
|
| 1284 | } |
|
| 1285 | } |
|
| 1286 | static::$needJoin = []; |
|
| 1287 | $cols = 'COUNT('; |
|
| 1288 | ||