cakephp 3.0 将两列中的值作为一列获取

cakephp 3.0 get values in two columns as one

我试图获取两列的倍数作为值,但在 cakephp 3.0 中出现错误

Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS (Transactions__amount * PluTransaction FROM transactions Transactions LEF'

  $result =  $this->Transaction->find('all', array(
      'conditions' => [
        'Transactions.house_id' => $houseId]
    ))->join([
      [
        'alias' => 'PluTransaction',
        'table' => 'plu_transactions',
        'type' => 'LEFT',
        'conditions' => 'PluTransaction.transaction_id = Transactions.id'
      ]
      ])->select(['Transactions.id',
    '(Transactions.amount * PluTransaction.item_quantity) AS TOTAL',  
  ]);

这不是您定义计算列的方式,请参阅文档

您必须使用 key => value 格式来分别定义别名和表达式。

$query = $this->Transaction->find('all', [
    'conditions' => [
        'Transactions.house_id' => $houseId
    ]
]);
$query
    ->select([
        'Transactions.id',
        'TOTAL' => $query->newExpr('Transactions.amount * PluTransaction.item_quantity')
    ])
    ->join(/* ... */)
    // ...