2

Hey i've got a pretty simple relationship in my Datamapper model..

in my model Ticket i hav:

var $has_one = array("user");

and when i try to

$ticket->user->get()->username;

it says:

DataMapper Error: 'ticket' is not a valid parent relationship for User. Are your relationships configured correctly?

i dont see the problem :/

Adnan
  • 25,882
  • 18
  • 81
  • 110
soupdiver
  • 3,504
  • 9
  • 40
  • 68

1 Answers1

2

What does your user model look like? Does it map back to the Ticket as well?

var $has_many = array("ticket");
onteria_
  • 68,181
  • 7
  • 71
  • 64
  • must i hav this back link or is it optionally? – soupdiver May 11 '11 at 11:00
  • You need to link back as such because otherwise the mapper has no way to tell how many tickets a user has. Say for example all users submitted only 1 ticket. If the system tried to guess, the whole thing would fall apart when a single user submits two tickets. – onteria_ May 11 '11 at 11:06