I NEED THE HELP AND REPLY CONFIRMATION FROM EXPERT URGENTLY
Hi Experts.
I have the scenario as mention in the below and would like to know that whether YII has the feature to perform this function or not.
scenario
I have three table (Schedule, Job, Company)
Schedule
-
id
-
job_id
-
…
Job
-
id
-
company_id
-
…
Company
-
id
-
company_name
-
…
In this case I like to show the company_name field of model "Company" in the model "Schedule" search listing page and also like to do filtering search by the field "company_name" at that model "Schedule". I defined the rules, relation, and search criteria for that purpose in the "Schedule" model as below
class Adre extends CActiveRecord
{
...........
..........
public $company_name;
public function rules()
{
return array(
...........................
............
// The following rule is used by search().
array('xxxx, xxxx, xxxxx, xxxxx, company_name', 'safe', 'on'=>'search'),
);
}
public function relations()
{
return array(
........
..........................
'job' => array(self::BELONGS_TO, 'Job', 'job_id'),
'company'=>array(self::BELONGS_TO, 'Company', array('company_id'=>'id'), 'through'=>'job'),
........
..........................
);
}
................
..........................
public function listsearch()
{
$criteria=new CDbCriteria;
$criteria->with = array('job', 'company');
$criteria->together= true;
.......................
.................
$criteria->compare('company.company_name',$this->company_name, true);
.......................
......
........
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}
................
..........................
}
every thing working fine and filter search on that field "company_name" is not working.
PLEASE someone let me know that filtering (filter search,e.g admin view) on "company_name(field)" under "schedule" model listing page (e.g. admin view) via "job" model is CAN DO in Yii OR NOT possible? I have been spent a lot time this but still no luck to solve it.
With Regards and thanks,