如何使用 CActiveDataProvider 在 yii 上运行此查询。
select co.name,re.company_id,re.person_name,re.last_login_at, (select count(*) from activity_logs ac where re.id = ac.user_id ) as count from Companies co inner join employees re on co.id = re .company_id 限制为 20;
招聘人员关系
public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return array( 'candidatesEmployers' => array(self::HAS_MANY, 'CandidatesEmployers', 'employer_id'), 'employerCandidateActivities' => array(self::HAS_MANY, 'EmployerCandidateActivities', 'employer_id'), 'city' => array(self::BELONGS_TO, 'Cities', 'city_id'), 'company' => array(self::BELONGS_TO, 'Companies', 'company_id'), 'interviews' => array(self::HAS_MANY, 'Interviews', 'employer_id'), 'jobs' => array(self::HAS_MANY, 'Jobs', 'employer_id'), ); }
公司关系
public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return array( 'city' => array(self::BELONGS_TO, 'Cities', 'city_id'), 'employers' => array(self::HAS_MANY, 'Employers', 'company_id'), ); }
ActivityLogs 关系
public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return array( ); }