Answer the question
In order to leave comments, you need to log in
How to select data from several linked tables in YII1 with one query through links?
Hello, I have 7 tables, here is the
screen
I made such connections
Contacts
public function relations()
{
return array(
'company' => array(self::BELONGS_TO, 'Company', 'company_id'),
);
}
public function relations()
{
return array(
'category' => array(self::BELONGS_TO, 'BusinessCategory', 'category_id'),
'contacts' => array(self::HAS_MANY, 'Contacts', 'company_id'),
'staffCompanies' => array(self::HAS_MANY, 'StaffCompany', 'company_id'),
);
}
public function relations()
{
return array(
'companies' => array(self::HAS_MANY, 'Company', 'category_id'),
);
}
public function relations()
{
return array(
'emailStaffCompanies' => array(self::HAS_MANY, 'EmailStaffCompany', 'staff_company_id'),
'networkStaffCompanies' => array(self::HAS_MANY, 'NetworkStaffCompany', 'staff_company_id'),
'phoneStaffCompanies' => array(self::HAS_MANY, 'PhoneStaffCompany', 'staff_company_id'),
'company' => array(self::BELONGS_TO, 'Company', 'company_id'),
);
}
public function relations()
{
return array(
'staffCompany' => array(self::BELONGS_TO, 'StaffCompany', 'staff_company_id'),
);
}
Contacts::model()->with('company')->findAll(array("condition"=>"user_id = $user_id"));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question