Relation in ActiveRecord

I’ve read tutorial here http://www.yiiframework.com/doc-2.0/guide-db-active-record.html

and saw this


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

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


Request::find()->joinWith('relationIDlocation')->where(['relationIDlocation.IDuser'=>$Locations->IDuser])->count();

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


'relationIDlocation.IDuser'

Show detailed error message.

This is full error message

Change




Request::find()->joinWith('relationIDlocation')->where(['rre_locations.IDuser'=>$Locations->IDuser])->count();



I know about it, I used


[Locations::getTableSchema()->name.'.IDuser'=>Yii::$app->user->getId()]

I thought there is another solution, but thank you.