fatal error when calling find_many
mrlami opened this issue · 2 comments
mrlami commented
has_many_through('Role', 'UserRoleMapping');
}
```
}
class Role extends Model {
```
public static $_table = '_roles';
public function users() {
$this->has_many_through('User', 'UserRoleMapping');
}
```
}
class UserRoleMapping extends Model {
```
public static $_table = '_user_role_mappings';
```
}
$user = Model::factory('User')->find_one(3800);
$user_roles = $user->roles()->find_many(); //*\* Fatal error: Call to a member function find_many() on a non-object**
treffynnon commented
This is not a library issue. You need to return the call to
has_many_through() from your roles() method.
On Jun 15, 2013 12:59 PM, "mrLami" notifications@github.com wrote:
has_many_through('Role', 'UserRoleMapping'); } } class Role extends Model { public static $_table = '_roles'; public function users() { $this->has_many_through('User', 'UserRoleMapping'); } } class UserRoleMapping extends Model { public static $_table = '_user_role_mappings'; } $user = Model::factory('User')->find_one(3800); $user_roles = $user->roles()->find_many(); //*\* Fatal error: Call to a member function find_many() on a non-object** — Reply to this email directly or view it on GitHubhttps://github.com//issues/66 .
mrlami commented
Thanks!