Created
April 15, 2014 05:26
-
-
Save mathewka/10704427 to your computer and use it in GitHub Desktop.
Zend Jon Table , ZF2 Join table example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace ''''''; | |
| use Zend\Db\TableGateway\AbstractTableGateway; | |
| use Zend\Db\Sql\Select; | |
| class TestFile extends AbstractTableGateway | |
| { | |
| public function __construct($adapter) | |
| { | |
| $this->table = 'table_name'; | |
| $this->adapter = $adapter; | |
| $this->initialize(); | |
| } | |
| public function Leases($poolid) | |
| { | |
| $result = $this->select(function (Select $select) use ($poolid) { | |
| $select | |
| ->columns(array( | |
| 'column1', | |
| 'column1', | |
| 'column1', | |
| 'column1' | |
| )) | |
| ->join('table2', 'table2.column1 = table1.column1', array( | |
| 'column', | |
| 'column' | |
| )) | |
| ->join('table3', 'table3.column = table1.column', array( | |
| 'column' | |
| )) | |
| ->join('table4', 'table4.column = table1.column', array( | |
| 'domain' | |
| ))->where->equalTo('table1.column', $value); | |
| }); | |
| return $result->toArray(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment