未找到列:'where子句‘中的1054个未知列'total_points’
保护$tableGateway;
public function __construct(TableGateway $tableGateway)
{
$this->tableGateway = $tableGateway;
}
public function fetchPoints$transaction_number)
{
$results = $this->tableGateway->select(
array('total_points' => new \Zend\Db\Sql\Expression("sum(points)")),
array('trxnumber' => $transaction_number)
);
return $results[0]['total_points'];
}它试图从哪里获取total_points列?我认为点是列,total_points是列。
发布于 2014-09-21 09:49:01
选择只接受一个参数"where“。您当前的查询是:
select * from my_table where total_points=sum(points)女巫正在抛出预期的错误。我是想说你想:
select sum(points) as total_points from my_table where trxnumber=X在这种情况下,您应该这样做:
$select = $this->tableGateway->getSql()->select();
$select
->columns(array('total_points' => new \Zend\Db\Sql\Expression("sum(points)")))
->where(array('trxnumber' => $transaction_number));
$result = $this->tableGateway->selectWith($select);https://stackoverflow.com/questions/25943787
复制相似问题