按相同的交易ID

时间:2017-05-10 14:15:08

标签: php mysql cakephp-3.0

我正在尝试使用相同的交易类型ID获取所有价格的计数,但我收到错误,不知道原因。

这是我的代码:

$Query =TableRegistry::get('Transactions')->find()->select('Transactions.price','Transactions.transactions_type_id')
    ->contain('TransactionsTypes');
 $Query->select([ 
              'Transactions.price' ,
              'count' => $Query->func()->count('*')
            ])  
          ->group('Transactions.transactions_type_id');

如果我要打印它,给我那个错误:

  

100   \ plugins \ Budgets \ src \ Controller \ PagesController.php(第143行)   object(Cake \ ORM \ Query){

'(help)' => 'This is a Query object, to get the results execute or iterate it.',
'sql' => 'SELECT Transactions.price AS `Transactions__price`, (COUNT(*)) AS `count` FROM transactions Transactions LEFT JOIN transactions_types TransactionsTypes ON TransactionsTypes.id = (Transactions.transactions_type_id) GROUP BY Transactions.transactions_type_id ',
'params' => [],
'defaultTypes' => [
    'Transactions__id' => 'integer',
    'Transactions.id' => 'integer',
    'id' => 'integer',
    'Transactions__transactions_type_id' => 'integer',
    'Transactions.transactions_type_id' => 'integer',
    'transactions_type_id' => 'integer',
    'Transactions__financial_year_id' => 'integer',
    'Transactions.financial_year_id' => 'integer',

哪个100是具有相同交易类型的价格的第一列的值! 那么如何获得具有相同交易类型ID的所有价格的计数?

谢谢

0 个答案:

没有答案