Code Snippets
Complement complex SQL in SYMFONY
http://propel.phpdb.org/trac/ticket/57
集計関数を使用する例
SELECT MIN(reserve.MINUTES_PER_UNIT), reserve.NUMBER_PER_UNIT
FROM reserve
WHERE reserve.TYPE='time' AND reserve.RESERVE_GROUP_ID=1
GROUP BY reserve.TYPE,reserve.RESERVE_GROUP_ID
$c = new Criteria();
$c->add(ReservePeer::TYPE, $reserve_type);
$c->add(ReservePeer::RESERVE_GROUP_ID, $reserve_group_id);
$c->addSelectColumn('MIN('.ReservePeer::MINUTES_PER_UNIT.')');
$c->addGroupByColumn(ReservePeer::TYPE);
$c->addGroupByColumn(ReservePeer::RESERVE_GROUP_ID);
$rs = ReservePeer::doSelectRS($c);
while ($rs->next())
{
$minutes_per_unit = $rs->getInt(1);
}