| @@ 646-663 (lines=18) @@ | ||
| 643 | App::$cur->db->join($join[0], $join[1]); |
|
| 644 | } |
|
| 645 | static::$relJoins = []; |
|
| 646 | foreach (static::$needJoin as $rel) { |
|
| 647 | $relations = static::relations(); |
|
| 648 | if (isset($relations[$rel])) { |
|
| 649 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 650 | switch ($type) { |
|
| 651 | case 'to': |
|
| 652 | $relCol = $relations[$rel]['col']; |
|
| 653 | static::fixPrefix($relCol); |
|
| 654 | App::$cur->db->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 655 | break; |
|
| 656 | case 'one': |
|
| 657 | $col = $relations[$rel]['col']; |
|
| 658 | $relations[$rel]['model']::fixPrefix($col); |
|
| 659 | App::$cur->db->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 660 | break; |
|
| 661 | } |
|
| 662 | } |
|
| 663 | } |
|
| 664 | static::$needJoin = []; |
|
| 665 | if (is_array($param)) { |
|
| 666 | App::$cur->db->where($param); |
|
| @@ 723-740 (lines=18) @@ | ||
| 720 | App::$cur->db->join($join[0], $join[1]); |
|
| 721 | } |
|
| 722 | static::$relJoins = []; |
|
| 723 | foreach (static::$needJoin as $rel) { |
|
| 724 | $relations = static::relations(); |
|
| 725 | if (isset($relations[$rel])) { |
|
| 726 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 727 | switch ($type) { |
|
| 728 | case 'to': |
|
| 729 | $relCol = $relations[$rel]['col']; |
|
| 730 | static::fixPrefix($relCol); |
|
| 731 | App::$cur->db->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 732 | break; |
|
| 733 | case 'one': |
|
| 734 | $col = $relations[$rel]['col']; |
|
| 735 | $relations[$rel]['model']::fixPrefix($col); |
|
| 736 | App::$cur->db->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 737 | break; |
|
| 738 | } |
|
| 739 | } |
|
| 740 | } |
|
| 741 | static::$needJoin = []; |
|
| 742 | ||
| 743 | if (!empty($options['limit'])) |
|
| @@ 1030-1047 (lines=18) @@ | ||
| 1027 | App::$cur->db->join($join[0], $join[1]); |
|
| 1028 | } |
|
| 1029 | static::$relJoins = []; |
|
| 1030 | foreach (static::$needJoin as $rel) { |
|
| 1031 | $relations = static::relations(); |
|
| 1032 | if (isset($relations[$rel])) { |
|
| 1033 | $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type']; |
|
| 1034 | switch ($type) { |
|
| 1035 | case 'to': |
|
| 1036 | $relCol = $relations[$rel]['col']; |
|
| 1037 | static::fixPrefix($relCol); |
|
| 1038 | App::$cur->db->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol); |
|
| 1039 | break; |
|
| 1040 | case 'one': |
|
| 1041 | $col = $relations[$rel]['col']; |
|
| 1042 | $relations[$rel]['model']::fixPrefix($col); |
|
| 1043 | App::$cur->db->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col); |
|
| 1044 | break; |
|
| 1045 | } |
|
| 1046 | } |
|
| 1047 | } |
|
| 1048 | static::$needJoin = []; |
|
| 1049 | $cols = 'COUNT('; |
|
| 1050 | ||