我想通过tablegateway加入许多表格。它工作正常,但当我加入一个具有相同列名的表时Zend抛出错误:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id_club' in where clause is ambiguous
我的代码如下:
$id = $pId_club;
$result = $this->tableGateway->select(function(Select $select) use ($id){
$select->join('vm_position', 'id_position = vm_position.id', array('name'))
->join('vm_club', 'id_club = vm_club.id', array('club_name'))
->join('vm_user', 'id_user = vm_user.id', array('login'))
->join('vm_squad', 'id_club = vm_squad.id_club', array())
->where(array('id_club' => $id))
->order('id_user ASC');
});
$row = $result->current();
return $row;
我在主表id_club
和'vm_match'
中有列'vm_squad'
。如果没有加入'vm_squad'
,它就会运作良好。