Welcome Guest, Not a member yet? Register   Sign In
DataMapper stumping me - almost works
#4

[eluser]BrianDHall[/eluser]
Thanks bretticus, you actually helped me solve my problem.

Just goes to show sometimes its best to leave something and come back later, and just the process of asking a question helps to answer it.

I went to create the post and found what I had done wrong. It was so utterly simple and basic I looked right past it. The ORM equivalent of using = where you meant to use ==, I think.

Incase others have a similar problem, here's what happened.
Code:
class Garagetype extends DataMapper {
    // Insert related models that Garagetype can have just one of.
    var $has_one = array();

    // Insert related models that Garagetype can have more than one of.
    var $has_many = array('listings');

And in the other model:

Code:
class Listing extends DataMapper {
    // Insert related models that Listing can have just one of.
    var $has_one = array('user', 'garagetype');

    // Insert related models that Listing can have more than one of.
    var $has_many = array();

Can you see the problem? I sure couldn't.

It was a real pain in the S...it was in Garagetype. It said it has many "listings", but notice how in Listing the reference is singular, not plural?

That's what it was. Ugh, now it works perfectly! And beautifully, really, so easy.

It's the one downside to magic systems - a small error can make things break without noticable error, something just stops working. Its always made me leary of them, but the truth is I've spent far more time hunting my own bugs than someone else's, so I shouldn't be so repelled by other peoples code Wink


Messages In This Thread
DataMapper stumping me - almost works - by El Forum - 09-03-2009, 01:52 PM
DataMapper stumping me - almost works - by El Forum - 09-03-2009, 02:16 PM
DataMapper stumping me - almost works - by El Forum - 09-03-2009, 04:13 PM
DataMapper stumping me - almost works - by El Forum - 09-04-2009, 12:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB