Index: trunk/extensions/EducationProgram/includes/EPMentor.php |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | */ |
79 | 79 | protected function doGetOrgs( $fields, array $conditions ) { |
80 | 80 | $conditions = array_merge( |
81 | | - array( array( 'ep_mentors_per_org', 'mentor_id' ), $this->getId() ), |
| 81 | + array( array( 'ep_mentors', 'id' ), $this->getId() ), |
82 | 82 | $conditions |
83 | 83 | ); |
84 | 84 | |
— | — | @@ -85,7 +85,10 @@ |
86 | 86 | $fields, |
87 | 87 | $conditions, |
88 | 88 | array(), |
89 | | - array( 'orgs' => array( 'INNER JOIN', array( array( array( 'ep_mentors_per_org', 'org_id' ), array( 'orgs', 'id' ) ) ) ) ) |
| 89 | + array( |
| 90 | + 'ep_mentors_per_org' => array( 'INNER JOIN', array( array( array( 'ep_mentors_per_org', 'org_id' ), array( 'orgs', 'id' ) ) ) ), |
| 91 | + 'ep_mentors' => array( 'INNER JOIN', array( array( array( 'ep_mentors_per_org', 'mentor_id' ), array( 'ep_mentors', 'id' ) ) ) ) |
| 92 | + ) |
90 | 93 | ); |
91 | 94 | } |
92 | 95 | |
Index: trunk/extensions/EducationProgram/includes/EPStudent.php |
— | — | @@ -86,12 +86,12 @@ |
87 | 87 | * |
88 | 88 | * @since 0.1 |
89 | 89 | * |
90 | | - * @param array|null $fields |
| 90 | + * @param string|array|null $fields |
91 | 91 | * @param array $conditions |
92 | 92 | * |
93 | 93 | * @return array of EPTerm |
94 | 94 | */ |
95 | | - public function getTerms( array $fields = null, array $conditions = array() ) { |
| 95 | + public function getTerms( $fields = null, array $conditions = array() ) { |
96 | 96 | if ( count( $conditions ) !== 0 ) { |
97 | 97 | return $this->doGetTerms( $fields, $conditions ); |
98 | 98 | } |
— | — | @@ -115,22 +115,22 @@ |
116 | 116 | * |
117 | 117 | * @since 0.1 |
118 | 118 | * |
119 | | - * @param array|null $fields |
| 119 | + * @param string|array|null $fields |
120 | 120 | * @param array $conditions |
121 | 121 | * |
122 | 122 | * @return array of EPTerm |
123 | 123 | */ |
124 | 124 | protected function doGetTerms( $fields, array $conditions ) { |
125 | | - $conditions = array_merge( |
126 | | - array( array( 'ep_students_per_term', 'student_id' ), $this->getId() ), |
127 | | - $conditions |
128 | | - ); |
| 125 | + $conditions[] = array( array( 'ep_students', 'id' ), $this->getId() ); |
129 | 126 | |
130 | 127 | return EPTerm::select( |
131 | 128 | $fields, |
132 | 129 | $conditions, |
133 | 130 | array(), |
134 | | - array( 'terms' => array( 'INNER JOIN', array( array( array( 'ep_students_per_term', 'term_id' ), array( 'terms', 'id' ) ) ) ) ) |
| 131 | + array( |
| 132 | + 'ep_students_per_term' => array( 'INNER JOIN', array( array( array( 'ep_students_per_term', 'term_id' ), array( 'ep_terms', 'id' ) ) ) ), |
| 133 | + 'ep_students' => array( 'INNER JOIN', array( array( array( 'ep_students_per_term', 'student_id' ), array( 'ep_students', 'id' ) ) ) ) |
| 134 | + ) |
135 | 135 | ); |
136 | 136 | } |
137 | 137 | |
Index: trunk/extensions/EducationProgram/includes/EPDBObject.php |
— | — | @@ -552,8 +552,8 @@ |
553 | 553 | static $prefixes = false; |
554 | 554 | |
555 | 555 | if ( $prefixes === false ) { |
556 | | - foreach ( $GLOBALS['egEPDBObjects'] as $classOrIndex => $object ) { |
557 | | - $prefixes[$object['table']] = $object['prefix']; |
| 556 | + foreach ( $GLOBALS['egEPDBObjects'] as $classInfo ) { |
| 557 | + $prefixes[$classInfo['table']] = $classInfo['prefix']; |
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
— | — | @@ -578,7 +578,7 @@ |
579 | 579 | * their values as value. The field names are prefixed with the |
580 | 580 | * db field prefix. |
581 | 581 | * |
582 | | - * Field names can also be provdied as an array with as first element a table name, such as |
| 582 | + * Field names can also be provided as an array with as first element a table name, such as |
583 | 583 | * $conditions = array( |
584 | 584 | * array( array( 'tablename', 'fieldname' ), $value ), |
585 | 585 | * ); |
— | — | @@ -775,7 +775,7 @@ |
776 | 776 | |
777 | 777 | $tables = array( static::getDBTable() ); |
778 | 778 | $joinConds = static::getProcessedJoinConds( $joinConds, $tables ); |
779 | | - |
| 779 | + |
780 | 780 | $result = static::rawSelect( |
781 | 781 | static::getPrefixedFields( $fields ), |
782 | 782 | static::getPrefixedValues( $conditions ), |
— | — | @@ -834,13 +834,21 @@ |
835 | 835 | static::getPrefixedField( $joinCondPart[0] ), |
836 | 836 | static::getPrefixedField( $joinCondPart[1] ), |
837 | 837 | ); |
838 | | - |
| 838 | + |
| 839 | + if ( !in_array( $joinCondPart[0][0], $tables ) ) { |
| 840 | + $tables[] = $joinCondPart[0][0]; |
| 841 | + } |
| 842 | + |
| 843 | + if ( !in_array( $joinCondPart[1][0], $tables ) ) { |
| 844 | + $tables[] = $joinCondPart[1][0]; |
| 845 | + } |
| 846 | + |
839 | 847 | $cond[1][] = implode( '=', $parts ); |
840 | 848 | } |
841 | 849 | |
842 | | - $conds = $cond; |
| 850 | + $conds[] = $cond; |
843 | 851 | } |
844 | | - |
| 852 | + //if (count($conds)) {q($conds);} |
845 | 853 | return $conds; |
846 | 854 | } |
847 | 855 | |
— | — | @@ -864,7 +872,7 @@ |
865 | 873 | |
866 | 874 | return count( $objects ) > 0 ? $objects[0] : false; |
867 | 875 | } |
868 | | - |
| 876 | + |
869 | 877 | /** |
870 | 878 | * Selects the the specified fields of the first record matching the provided |
871 | 879 | * conditions and returns it as an associative array, or false when nothing matches. |
— | — | @@ -957,7 +965,7 @@ |
958 | 966 | |
959 | 967 | /** |
960 | 968 | * Update the records matching the provided conditions by |
961 | | - * setting the fields that are keys in the $values patam to |
| 969 | + * setting the fields that are keys in the $values param to |
962 | 970 | * their corresponding values. |
963 | 971 | * |
964 | 972 | * @since 0.1 |