Welcome Guest, Not a member yet? Register   Sign In
Query Join Table In Where Clause Using DataMapper
#1

[eluser]Vheissu[/eluser]
I am building a simple classifieds system and using DataMapper Overzealous Edition as my ORM of choice. Basically a listing is assigned to a category and I want to be able to query a listing via its category. See below for some code of how I think it would work, is this correct or do I need to instantiate a new "Category" model object as well?

Code:
$l = new Listing();
$l->where('status', 'active');
$l->category->where('name', 'electronics');
$l->get();

Would the above code work for retrieving all listings assigned to the "electronics" category and if not, how would I go about doing this?

Also I am not populating relationships automatically, all relationships to other models are done manually as needed for performance reasons if that helps.


Messages In This Thread
Query Join Table In Where Clause Using DataMapper - by El Forum - 08-01-2011, 06:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB