Php 带有联接异常的zf2分页器
我在对join使用分页时遇到问题。我有这个函数 AllowanceApprovalTable.phpPhp 带有联接异常的zf2分页器,php,mysql,zend-framework,zend-framework2,zend-db,Php,Mysql,Zend Framework,Zend Framework2,Zend Db,我在对join使用分页时遇到问题。我有这个函数 AllowanceApprovalTable.php public function fetchAll($paginated = false) { if ($paginated) { // create a new Select object for the table album $select = new Select('approval_for_allowances');
public function fetchAll($paginated = false) {
if ($paginated) {
// create a new Select object for the table album
$select = new Select('approval_for_allowances');
$select->columns(array('*'), false);
$select->join('institutes', 'institutes.id=approval_for_allowances.institute_id', Select::SQL_STAR, Select::JOIN_RIGHT);
// create a new result set based on the Album entity
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new AllowanceApproval());
// create a new pagination adapter object
$paginatorAdapter = new DbSelect(
// our configured select object
$select,
// the adapter to run it against
$this->tableGateway->getAdapter(),
// the result set to hydrate
$resultSetPrototype
);
$paginator = new Paginator($paginatorAdapter);
return $paginator;
}
$select = new Select('approval_for_allowances');
$select->columns(array('*'));
$select->join('institutes', 'institutes.id=approval_for_allowances.institute_id', Select::SQL_STAR, Select::JOIN_RIGHT);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
我有这个函数
if语句外的代码工作正常,内部代码号显示以下消息:
语句无法执行(42S21-1060-重复的列名'id')我找到了答案
if ($paginated) {
// create a new Select object for the table album
$select = new Select('approval_for_allowances');
$select->columns(array('*'));
$select->join('institutes', 'institutes.id=approval_for_allowances.institute_id', array('*'), 'left');
// create a new result set based on the Album entity
// create a new pagination adapter object
$paginatorAdapter = new DbSelect(
// our configured select object
$select,
// the adapter to run it against
$this->tableGateway->getAdapter()
);
$paginator = new Paginator($paginatorAdapter);
return $paginator;
}