Answer the question
In order to leave comments, you need to log in
How Yii1 correctly set the scope for the model?
Good afternoon,
There is such a scope (relationship MANY_MANY ) in the Users table:
public function scopes() {
return array_merge (
parent::scopes(), [
'holder' => [
'with' => [
'tenant' => [
'condition' => 'id=:tenant_id',
'params' => [
':tenant_id' => Tenants::getTenantID()
]
]
]
],
]
);
}
public function relations() {
return [
'tenant' => [self::MANY_MANY, 'Tenants', 'l_users_22_tenants(id_1, id_2)'],
]
}
$customers = Users::model()->holder()->findAll();
Answer the question
In order to leave comments, you need to log in
mysql swears because it doesn't know which id to use'condition' => 'tenant.id=:tenant_id',
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question