Relation in ActiveRecord

I’ve read tutorial here

and saw this

$orders = Order::find()->joinWith('customer')->orderBy(',')->all();

I tried to do similar with my query but it doesn’t work, not sure why.


Could someone point out why is that. Everything is set up properly.

    public function getRelationIDlocation()


        return $this->hasOne(Locations::className(), ['ID' => 'IDlocation']);


What is your goal and most what does not work?

It’s not clear.

My goal is to count number of records in different table where IDuser is for example 2,3,4…

This doesn’t work


Show detailed error message.

This is full error message



I know about it, I used


I thought there is another solution, but thank you.