0

私はこのクエリに遅れがあります:

            $result = $qb->select("p,s,t,w,ph")
                      ->from("Entity\Property", "p")
                      ->innerJoin("p.sub_type","s")
                      ->innerJoin("s.type","t")
                      ->innerJoin("p.web_info","w")
                      ->leftJoin("p.photos","ph")
                      ->where("w.publish_on_trovit > 0")
                      ->andWhere("p.status=0")
                      ->add("orderBy","p.id ASC,ph.display_order ASC")
                      ->setFirstResult($offset)
                      ->setMaxResults($limit)
                      ->getQuery()
                      ->getArrayResult();

問題はエンティティ全体の負荷であり、ラグを解決するには、必要なテーブル フィールドのみを選択する必要があります。

しかし、「p、ph」の代わりに「p.id、ph.id」を使用すると、教義の隠蔽により、結果配列が通常のSQL結合のようなフラットテーブルに変更されます。

上記のクエリの結果のように、parenet->chields 結果セットに必要なフィールドのみをロードする方法はありますか?

ありがとう!

4

1 に答える 1

0

部分的に使用して解決されたツリー構造が維持されます。

select("partial p.{id,reference},partial ph.{id,name},partial t.{id,name},partial s.{id,name},partial w.{id}")

var_dump

array
  0 => 
    array
      'id' => int 9
      'reference' => string '9' (length=1)
      'sub_type' => 
        array
          'id' => int 1
          'name' => string 'Padrao' (length=6)
          'type' => 
            array
              ...
      'web_info' => 
        array
          'id' => int 9
      'photos' => 
        array
          empty
  1 => 
    array
      'id' => int 16
      'reference' => string '124793' (length=6)
      'sub_type' => 
        array
          'id' => int 1
          'name' => string 'Padrao' (length=6)
          'type' => 
            array
              ...
      'web_info' => 
        array
          'id' => int 16
      'photos' => 
        array
          empty
于 2012-06-21T20:36:07.033 に答える