[eluser]Unknown[/eluser]
Hi everybody:
i'm working on my first CI project and I decided to use DMZ as well - just to keep things simple! I've run into a problem I don't really understand... I have three models: document, user and line. Relationships are defined as follows:
Code:
class Document extends DataMapper {
var $table = 'documents';
var $model = 'document';
var $has_one = array('user');
...
Code:
class User extends DataMapper {
var $table = 'users';
var $model = 'user';
var $has_one = array('line','document');
...
and finally
Code:
class Line extends DataMapper {
var $table = 'lines';
var $model = 'line';
var $has_many = array('user');
...
Then in my controller I pass an $id for user, so that I can load:
Code:
$user = new User($id);
Easily enough, I can get the line for user by setting:
And now I would like to get the document for the user (which is a one-to-one relation which I have set up with an auxiliary table, BTW), but when I do this:
Code:
$user->document->get();
I get an error: "
Fatal error: Call to a member function get() on a non-object".
Does anybody know what I'm doing wrong?
Thanks for the help,
Antonio