protected function getSalesByMonth($em, $dateTime, array $excludes)
{
// concat... for pgsql
// http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
$dql = 'SELECT
SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) AS order_month,
SUM(o.payment_total) AS order_amount,
COUNT(o) AS order_count
FROM
Eccube\\Entity\\Order o
WHERE
o.del_flg = 0
AND o.OrderStatus NOT IN (:excludes)
AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) = SUBSTRING(:targetDate, 1, 7)
GROUP BY
order_month';
$q = $em->createQuery($dql)->setParameter(':excludes', $excludes)->setParameter(':targetDate', $dateTime);
$result = array();
try {
$result = $q->getSingleResult();
} catch (NoResultException $e) {
// 結果がない場合は空の配列を返す.
}
return $result;
}