[eluser]matthewwithanm[/eluser]
Could somebody tell me what I'm doing wrong with include_related? I have these models:
Code:
class User extends Datamapper {
public $has_one = array('group');
}
class Group extends Datamapper {
public $has_many = array('user');
}
My db has two tables: users (with id, name and group_id fields) and groups (with id and name fields).
I have the following code in a controller taken almost verbatim from the docs:
Code:
$users = new User();
$users->include_related('group', array('id', 'name'), TRUE, TRUE)->get();
foreach ($users as $user)
{
echo "<li>{$user->group->name}</li>";
echo "<li>{$user->group_name}</li>";
}
The output is:
Code:
* The Group's Name
*
In other words, I can't access the property through the instantiated related object. Am I doing something wrong? Or is there a bug in the newest DataMapper?