• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.