0
Using Yii2, I want to get the result of the following consultation:
SELECT data_pagamento, sum(valor_pago)
FROM tbl_finlegado_titulo_parcela_baixa
WHERE MONTH(data_pagamento) = 10
GROUP BY DAY(data_pagamento)
Using the find method, it does not return me the field valor_pago
:
$baixas = self::find()
->select('data_pagamento, SUM(valor_pago)')
->where(['=', "MONTH(data_pagamento)", date('m')])
->groupBy('DAY(data_pagamento)')
->all();
Is it serious that solved? It was a very well given kick.
– Wallace Maxters
Seriously, then I went to see that he makes the association of the query alias to the property of the object being accessed.
– Marcelo de Andrade
@Marcelodeandrade, then it was really the question that happens in
Laravel
. Exactly the same thing.– Wallace Maxters
The same thing happened right after I needed to give one
SELECT DAY(data_pagamento) AS data_pagamento
. It automatically already makes the value associations.– Marcelo de Andrade