LoginSignup
3
3

More than 5 years have passed since last update.

symfony 2.6 Doctrineセレクト条件の指定方法

Last updated at Posted at 2015-03-24

Doctrineセレクト条件の指定で少しはまったら追記していきます。

  • hogeテーブルからデータを抽出します。
    • id: int型, count: int型, target_date: date型のカラムが存在する
    • AppBundle\Entity\Hogeエンティティにマッピングします

共通部分

カスタムRepository内での操作
$qb = $this->getEntityManager()
           ->createQueryBuilder('h')
           ->select('h')
           ->from('AppBundle\Entity\ Hoge', 'h');

Between

カスタムRepository内での操作
$between = array('start' => '2015-01-01', 'end' => '2015-12-31');
$query = $qb->where($qb->expr()->between('h.targetDate', ':start', ':end'))
            ->setParameters($between)
            ->getQuery();
$query->getResult();

その他

後日追記していきます。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3