A
A
atis //2016-07-27 13:46:04
Yii
atis //, 2016-07-27 13:46:04

How to get the sum of items using relays in Yii2?

class Customer
{
    /** @var $totalHouses total Houses */
    public $totalHouses;

    /** @var $houses array of Houses */
    public $houses;

    /** @var $sum total sum of Houses */
    public $sum;
}

class House
{
    /** @var $District District */
    public $District;

    /** @var $cost float */
    public $cost;

    /** @var $customer Customer|null */
    public $Customer;
}

class District
{
    /** @var $totalHouses total Houses */
    public $totalHouses;

    /** @var $houses array of Houses */
    public $houses;

    /** @var $sum total sum of Houses */
    public $sum;
}

links:
houses.customer_id = customer.id
houses.district_id = district.id
how to get the total amount of houses from a buyer?
how to find out the total amount of houses in the area?
how to find out the total number of houses in the area?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
atis //, 2016-07-27
@atis2345

So here it is:
sum + yii2 relation
How get sum of field in the related table in one q...
The only thing that is not very good is that "greedy" loading does not work!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question