a tiny mvc framework for php using php-activerecord
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Eager loading is working #107 for non-namespaced classes.

+30 -3
+21 -1
lib/php-activerecord/lib/Relationship.php
··· 147 147 148 148 if (!empty($includes)) 149 149 $options['include'] = $includes; 150 - 150 + 151 + if (!empty($options['through'])) { 152 + // save old keys as we will be reseting them below for inner join convenience 153 + $pk = $this->primary_key; 154 + $fk = $this->foreign_key; 155 + 156 + $this->set_keys($this->get_table()->class->getName(), true); 157 + 158 + $class = isset($options['class_name']) ? 159 + $options['class_name'] : 160 + classify($options['through'], true); 161 + $through_table = $class::table(); 162 + $options['joins'] = $this->construct_inner_join_sql($through_table, true); 163 + 164 + $query_key = $this->primary_key[0]; 165 + 166 + // reset keys 167 + $this->primary_key = $pk; 168 + $this->foreign_key = $fk; 169 + } 170 + 151 171 $options = $this->unset_non_finder_options($options); 152 172 153 173 $class = $this->class_name;
+9 -2
lib/php-activerecord/test/HasManyThroughTest.php
··· 46 46 } 47 47 48 48 public function test_gh107_has_many_through_include_eager() { 49 + $venue = Venue::find(1, array('include' => array('events'))); 50 + $this->assert_equals(1, $venue->events[0]->id); 51 + 52 + $venue = Venue::find(1, array('include' => array('hosts'))); 53 + $this->assert_equals(1, $venue->hosts[0]->id); 54 + } 55 + 56 + public function test_gh107_has_many_though_include_eager_with_namespace() { 49 57 $user = User::find(1, array( 50 58 'include' => array( 51 59 'newsletters' ··· 54 62 55 63 $this->assert_equals(1, $user->id); 56 64 $this->assert_equals(1, $user->newsletters[0]->id); 57 - } 65 + } 58 66 } 59 - 60 67 # vim: noet ts=4 nobinary 61 68 ?>