[eluser]madwhistler[/eluser]
Kudos & genuflections, first off, to OverZealous and all others who've helped organize and maintain a great product. It's a huge boon to info-modelers suffering with PHP.
My problem: I'm trying to construct complex queries to filter results (a pretty standard multi-field search), but with some filters drawn from related tables.
My model (simplified): Asset has-one Property, Property has-one Address. It's has-many in the other direction. I need to filter which Assets are in Georgia. One way:
Code:
$assets = new Asset();
$a = new Address();
$a->where('state','GA')->get();
$a->property->get();
$assets = $a->property->asset->get();
All well and good, but it's not exactly a SQL Where clause. What if I now want to add a second filter, for Asset->value > $10000? That's an easy query:
Code:
$assets->where('value >','10000')->get();
But, how can I construct a way to flexibly 'AND' these queries together? If I could figure out a way to do the first query as a WHERE clause, I could just construct a bunch of $asset->where() calls and run one big get() to apply the whole multi-filter.
Unfortunately, these relations have got me bollixed up. I don't really want to get into the horrible world of subqueries, and I'm not sure they'd help anyway. Any advice?
Thanks in advance...