0

So Zend_db_select has the methods

  `joinUsing(table, join, [columns]) and joinInnerUsing(table, join, [columns])`

  `joinLeftUsing(table, join, [columns])`

  `joinRightUsing(table, join, [columns])`

  `joinFullUsing(table, join, [columns])`

etc

but what if you want to join 3 or more tables (eg for a many to many association)....eg: this query:

 SELECT * FROM (j LEFT JOIN e ON j.id = e.eee) LEFT JOIN w ON w.www = e.id

how would you go about doing this with zend_db_select

Charles
  • 50,943
  • 13
  • 104
  • 142
kamikaze_pilot
  • 14,304
  • 35
  • 111
  • 171

2 Answers2

0

Try use subquery and Zend_Db_Expr. Read more here.

KomarSerjio
  • 2,861
  • 1
  • 16
  • 12
0

Try doing ... but i am not so sure works with two fields but have not tried with 3 fields

$dbmodel->select(false)
    ->setIntegrityCheck(false)
    ->from(array('t1' => 'table1'))
    ->joinLeft(array('t2' => 'table2'),                                             
        't1.somefeild = t2.somefeild')
    ->joinLeft(array('t3' => 'table3'),                                             
        't2.somefeild = t3.somefeild')

you try to build query, and also you can check query by die((string)$select)

S L
  • 14,262
  • 17
  • 77
  • 116