Welcome Guest, Not a member yet? Register   Sign In
Datamapper relationship problems
#1

[eluser]Iverson[/eluser]
I have three models with the following relationships:

Code:
//Poll.php
var $has_many = array('poll_answer');

//Poll_answer.php
var $has_many = array('poll_vote');

//Poll_vote.php
var $has_one = array('poll_answer');

When I save a vote, the relationships get added fine. However this doesn't return anything at all:

Code:
$p->get_by_id($id);
$p->poll_answer->get();
$p->poll_answer->poll_vote->get();

No clue...
#2

[eluser]OverZealous[/eluser]
Iverson,

Did you ever get this working?

In your example, you need to have a has_one or has_many in poll_answer for poll. You always need to have both sides of every relationship.

Otherwise, you haven't provided too much to go on here. Try turning on profiling, and checking the SQL queries. See if something is out of place. Run the queries directly on your DB to see what you get. Make sure you get a result for the second line ($p->poll_answer).
#3

[eluser]Iverson[/eluser]
[quote author="OverZealous.com" date="1237795004"]Iverson,

Did you ever get this working?

In your example, you need to have a has_one or has_many in poll_answer for poll. You always need to have both sides of every relationship.

Otherwise, you haven't provided too much to go on here. Try turning on profiling, and checking the SQL queries. See if something is out of place. Run the queries directly on your DB to see what you get. Make sure you get a result for the second line ($p->poll_answer).[/quote]

How did I miss that? :-S




Theme © iAndrew 2016 - Forum software by © MyBB