0

Symfony 1.4 とドクトリンを使用しています。左結合でクエリを作成したい:

SELECT * FROM table1 LEFT JOIN table2 on table1.id = table2.table1_id ...

私はこのようにしました:

Doctrine_Query::create()
->select('*')
->from('Table1 t')
->leftJoin('Table2 t2')
...

Table1 と Table2 の間に schema.yml 関係があります

  relations:
    Table2:
      class:          Table2
      local:          id
      foreign:        table1_id
      onDelete:       cascade
      type:           one
      foreignType:    one
      foreignAlias:   Table1Table2

最後に、次のようなクエリを取得します。

SELECT * FROM table1, table2 ...

LEFT JOIN 句はありません。理由を知っている人はいますか?

4

1 に答える 1

1

join構文に関しては、結合されたテーブルの指示対象を指定する必要があります ( を参照leftJoin)。

$q = Doctrine_Query::create()
        ->select('*')
        ->from('Table1 t')
        ->leftJoin('t.Table2 t2')
于 2012-07-12T08:34:04.373 に答える