[Deprecated] DMZ 1.5.4 (DataMapper OverZealous Edition) |
[eluser]OverZealous[/eluser]
@OES DMZ (or ActiveRecord, for that matter) has no special provisions for subqueries. The best bet is to build the subquery manually and add it using AR methods. Code: $order->db->join(...); You might be better off adding your column using a select statement, though, since it isn't used in the query elsewhere: Code: $sql = '(SELECT SUM(overs) FROM extras WHERE extras.order_id = orders.id) as overs'; Also, I believe group_by can be used for this, as just discussed the other day, but I make no promises. I think the group_by method is faster for the database. Of course, I'm somewhat talking out my *** about performance. ;-) |
Welcome Guest, Not a member yet? Register Sign In |