0

長い間検索しましたが、1 つのクエリで 2 つの関連オブジェクトを取得できません。DoctrineSymfonyを使用しています (デフォルトで Doctrine を使用しています)。

これが私のschema.ymlの一部です:

Member:
  columns:
    ...some fields...

Report:
  columns:
    member:       { type: integer, notnull: true }
    ...some fields...
  relations:
    Member:  { onDelete: CASCADE, local: member, foreign: id, foreignAlias: Members }

そして、これはレポートオブジェクトのみを取得するために機能する私の「基本的な」リクエストです:

public function getReports($place,$max = 5) {
    $q = Doctrine_Query::create()
            ->from('Report sr')
            ->where('sr.place = ?',$place)
            ->limit($max)
            ->orderBy('sr.date DESC');
    return $q->execute();
}

場所のメンバーによってレポートがコミットされました。メンバー オブジェクトを取得してフィールドと共に表示する必要がありますが、その方法がわかりません。

それを行う手がかりや方法があれば、本当に助かります。

4

1 に答える 1

1
$q = Doctrine_Query::create()
->from('Report sr')
->innerJoin('sr.Members m');

それだけです、非常に簡単です:)

于 2010-07-16T17:13:18.637 に答える