Skip to content

Instantly share code, notes, and snippets.

@mathewka
Created April 15, 2014 05:26
Show Gist options
  • Select an option

  • Save mathewka/10704427 to your computer and use it in GitHub Desktop.

Select an option

Save mathewka/10704427 to your computer and use it in GitHub Desktop.
Zend Jon Table , ZF2 Join table example.
<?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