[eluser]papercut[/eluser]
I did that.
Here's how I defined them:
models/session.php
Code:
class Session extends DataMapper {
var $has_many = array('track', 'user');
var $has_one = array('author' => array('class' => 'user', 'other_field' => 'authored'));
}
models/user.php
Code:
class User extends DataMapper {
var $has_many = array('track', 'user', 'authored' => array('class' => 'session', 'other_field' => 'author'));
}
controllers/test.php
Code:
$s->author->get();
echo("Author name: " . $s->author->name . "<br>");
echo("Author e-mail: " . $s->author->email . "<br>");
And this is the error message:
Quote:Error Number: 1054
Unknown column 'authored_sessions_users.authored_id' in 'where clause'
SELECT `users`.* FROM (`users`) LEFT OUTER JOIN `sessions_users` authored_sessions_users ON `users`.`id` = `authored_sessions_users`.`author_id` WHERE `authored_sessions_users`.`authored_id` = 2
I have tried to do this in many different ways. I've also tried to specify the foreign-key names, etc.
Thanks for your reply!
EDIT: This is weird because I just tried to output information about the author (the one-to-many part), so it shouldn't go to the join table, sessions_users. Right?