Exception Join in Zend\Db 2.8.2 (DB2)

For programming and general questions on Zend Framework

Exception Join in Zend\Db 2.8.2 (DB2)

Postby dan8246 on Fri Apr 06, 2018 5:00 pm

I can't seem to figure out how to create an exception join using Zend\Db?

Is the only way to use:
Code: Select all
$db->query('Select * from....')
dan8246
 
Posts: 37
Joined: Fri Jan 23, 2015 5:53 pm

Re: Exception Join in Zend\Db 2.8.2 (DB2)

Postby dan7234 on Wed Apr 11, 2018 3:04 pm

I cross posted and received an answer on stackoverflow.

Note*: I had to insert '+' throughout this post in order to submit, I'm not allowed to post links and it thinks some of the table qualifiers are links.

https://stackoverflow+.+com/questions/49762937/exception-join-in-zend-db-2-8-2-db2

To recap:

Code: Select all
select a+.+id, a.description, b+.+name
  from table1 a
    left exception join table2 b
      on a+.+id = b+.+id


I equivalent to:

Code: Select all
select a+.+id, a.description, b+.+name
  from table1 a
    left outer join table2 b
      on a+.+id = b+.+id
  where b+.+id is null


So something like this would work:

Code: Select all
$select = new Select();
$select->columns(array('id', 'description'));
$select->from(array('a' => 'table1'));
$select->join(
    array('b' => 'table2'),
    'b+.+id = a+.+id',
    array('name'),
    $select::OUTER
);
$select->where(array('b+.+id' => null));
dan7234
 
Posts: 6
Joined: Wed Nov 26, 2014 7:50 pm


Return to Zend Framework

Who is online

Users browsing this forum: No registered users and 1 guest