Using Zend_Db_Select to include several tables in one join

78 views Asked by At

I know usage of Zend_Db_Select is optional, but I was wondering if there was a way to use it to generate the following SQL:

         LEFT JOIN (pages p
             , core_url_rewrite url)
            ON p.page_id = mi.page_id
           AND url.page_id = p.page_id

.. or if that's not supported. From what i can see you can only join one table at a time. If u include the tables as a Zend_Db_Expr:

->joinLeft(new Zend_Db_Expr('(pages p, core_url_rewrite url)'), 
    'ON p.page_id = mi.page_id
    AND url.page_id = p.page_id')

then i'd end up with something like the following, which isn't valid

         LEFT JOIN (pages p
             , core_url_rewrite url) AS t
            ON p.page_id = mi.page_id
           AND url.page_id = p.page_id
1

There are 1 answers

0
dvir On BEST ANSWER

Multiple tables JOINs are not supported. Zend_Db_Select is programmed to support only one array element as the join table parameter name, and in case it is a Zend_Db_Expr or Zend_Db_Select instance it will assign it the alias 't', assuming that you are entering a single table name / expression.

You can just split it into two joinLeft's, which might be better for future maintaining, and has no difference from what you wanted.