Reputation: 1
Please help me to convert this query into cakePHP find statement --
mysql> select auctions.id, auctions.price, products.target_price, (auctions.price / products.target_price) as target_ratio FROM auctions LEFT JOIN products ON auctions.product_id = products.id ORDER BY target_ratio DESC;
In particular, I've having difficulty getting this sections to work:
(auctions.price / products.target_price) as target_ratio
Thanks!
Upvotes: 0
Views: 131
Reputation: 521995
For the ratio part you should use Virtual Fields.
The join should be done automatically if your models have a belongsTo or hasOne relationship, otherwise you can join them manually.
Upvotes: 2