Closed snetty closed 11 years ago
@snetty can you give me some code examples?
I was actually struggling with this in LS yesterday. If you dig around in their AR you'll find that they have an unimplemented 'finder_sql' option on a relation definition which allows you to just pass it the SQL to use to create the join. Problem with that is that it won't give you the ability to add models to the relation, it would be read only.
So in summary, think it would be better to allow calculated columns to return multiple rows. So for example, you could set up a calculated column on the Shop_Customer model that shows all the products that customer has bought (obviously via the Order and Order Item tables)
I'm almost certain this exists already. Has many relationships will show a string separated with commas. Is this what you mean?
Maybe submit a pull request so I can see what you mean. Seeing code helps.
would want to be able to access the model rather than just 1 value though, so something like this
$calculated_columns = array(
'purchased_products' => array(
'sql' =>'SOME SQL QUERY THAT RETURNS ALL THE PRODUCTS TAHT A CUSTOMER HAS BOUGHT',
'type' => 'Shop_Product')
);
then usage
$purchased_products = $customer->purchased_products;
foreach($purchased_products as $purchased_product){
echo $purchased_product->price;
}
Oh I get you now. I will see if this is possible currently. I'm pretty sure you could do it using a custom column with an eval prefix function. Have you tried that?
/me stares blankly, erm yeah that'd work.. not embarrassed at all
All good then! :100:
Haven't actually checked this, but earlier issue reminded me of a feature I really want.
Can you please add order, limits and possibly extra joins to relations, my Hosting module has to jump through some ridiculously expensive hoops to get the relations I need.