I would like to do a simple INNER JOIN
between two tables in Zend2.
Concretely, I would like to do this in Zend2:
SELECT * FROM foo, bar WHERE foo.foreign_id = bar.id;
I have a FooTable
:
class FooTable
{
protected $tableGateway;
public function __construct(TableGateway $tableGateway)
{
$this->tableGateway = $tableGateway;
}
public function get($id)
{
$rowset = $this->tableGateway->select(function (Select $select) {
$select->from('foo');
});
}
}
The $select->from('foo');
returns an error:
==> Since this object was created with a table and/or schema in the constructor, it is read only.
So, I can't tweak my FROM statement to match a simple inner join between FooTable
and BarTable
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…