相关疑难解决方法(0)

TableGateway具有多个FROM表

我想INNER JOIN在Zend2中的两个表之间做一个简单的操作.

具体来说,我想在Zend2中这样做:

SELECT * FROM foo, bar WHERE foo.foreign_id = bar.id;

我有一个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');
    });
  }
}
Run Code Online (Sandbox Code Playgroud)

$select->from('foo');返回一个错误:

==> 由于此对象是在构造函数中使用表和/或模式创建的,因此它是只读的.

所以,我不能调整我的FROM语句来匹配FooTable和之间的简单内连接BarTable.

php zend-framework2 tablegateway

5
推荐指数
1
解决办法
8050
查看次数

标签 统计

php ×1

tablegateway ×1

zend-framework2 ×1