I am having a trouble defining relation with order
In Yii 1 the relation is defined as such…
‘nameservers’ => array(self::MANY_MANY, ‘YHost’, ‘host_domain(domain_id, host_id)’, ‘order’=>‘nameservers_nameservers.is_master desc, nameservers_nameservers.host_domain_id’, ‘condition’=>“status=‘A’”)
host_domain is a pivot table and includes
domain_id (int), host_id (int), is_master (boolean), host_domain_id (int)
the main table is domains, with pk domain_id (int)
I can get everything except the order to work with a relation like…
$this->hasMany(‘YHost’,[‘host_id’=>‘host_id’])->viaTable(“host_domain”,[‘domain_id’=>‘domain_id’)->andWhere(“status=‘A’”)->all();
If I try to define the orderBy I get error that the table can’t be found because the final query is split into at least two queries…
Can anyone help me how to define this relation such as the orderBy can be used in a successful way?