Suraj Maurya
Suraj Maurya

Reputation: 43

Dynamic query where clause in yii

I have this query

$res = propertyDetail::find()
    ->joinWith('propertyImages')
    ->all();

$res = $res->where(['pkPropertyIDPrimary' => 1]);

I receive this error:

Call to a member function where() on array

This query contains a property Image and property detail records. Now I want to add a where clause in this dynamic.

How can I do this?

Upvotes: 0

Views: 768

Answers (1)

GAMITG
GAMITG

Reputation: 3818

You need to do this way,

$res =  propertyDetail::find()
        ->joinWith('propertyImages');

$res = $res->where(['pkPropertyIDPrimary' => 1])->all();

Upvotes: 1

Related Questions