6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JoolenAdvent Calendar 2019

Day 10

テーブルをjoinせずに値を取ってみた

Posted at

Eccubeでdoctrineのselect()で遊んでみた記録です。

OrderにOrderStatusをjoinせずに受注ステータスを取ってみました。

まずは、OrderRepositoryの$qbの用意

$qb = $GLOBALS['kernel']->getContainer()
      ->get(\Eccube\Repository\OrderRepository::class)
      ->createQueryBuilder('o');

joinせずに受注ステータスを取ってみた

$qb
    ->select(
        '(SELECT os.name FROM \Eccube\Entity\Master\OrderStatus AS os WHERE os = o.OrderStatus)'
    );

$qb->getQuery()->getResult();

select()に入れればなんでもできそうでなかなか面白いです。

*素晴らしいSQLを目指したものではなく、ただの遊びです。

6
2
3

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
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?