$widgets = Doctrine_Query::create() ->select('w.*, p.*, COUNT(p.partid) count') ->from('Widget w') ->leftJoin('w.Parts p') ->groupBy('w.widgetid') ->orderBy('count') ->execute();