如何使用yii连接3个模型以在cgridview中显示数据 /** * This is the model class for table "phone_number_group_assignment". * * The followings are the available columns in table 'phone_number_group_assignment': * @property integer $id * @property integer $phone_number_id * @property integer $group_id * @property integer $created_user * @property string $created_date * @property integer $modified_user * @property string $modified_date * * The followings are the available model relations: * @property UsersPhoneNumbers $phoneNumber */ class assignment extends CActiveRecord { /** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return assignment the static model class */ public static function model($className=__CLASS__) { return parent::model($className); } /** * @return string the associated database table name */ public function tableName() { return 'phone_number_group_assignment'; } /** * @return array validation rules for model attributes. */ public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( array('phone_number_id, group_id, created_date', 'required'), array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true), array('modified_date', 'safe'), // The following rule is used by search(). // Please remove those attributes that should not be searched. array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'), ); } /** * @return array relational rules. */ 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( 'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'), ); } /** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array( 'id' => 'ID', 'phone_number_id' => 'Phone Number', 'group_id' => 'Group', 'created_user' => 'Created User', 'created_date' => 'Created Date', 'modified_user' => 'Modified User', 'modified_date' => 'Modified Date', ); } /** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria=new CDbCriteria; $criteria->compare('id',$this->id); $criteria->compare('phone_number_id',$this->phone_number_id); $criteria->compare('group_id',$this->group_id); $criteria->compare('created_user',$this->created_user); $criteria->compare('created_date',$this->created_date,true); $criteria->compare('modified_user',$this->modified_user); $criteria->compare('modified_date',$this->modified_date,true); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, )); } }
我是yii框架的新手。我有3个表表表A、表B、表C。表A和表B与主键和外键关系相关。表B和表C与主键和外键关系链接的方式相同。我想在管理页面的cgridview中显示、筛选数据。使用yii fra如何使用yii连接3个模型以在cgridview中显示数据 /** * This is the model class for table "phone_number_group_assignment". * * The followings are the available columns in table 'phone_number_group_assignment': * @property integer $id * @property integer $phone_number_id * @property integer $group_id * @property integer $created_user * @property string $created_date * @property integer $modified_user * @property string $modified_date * * The followings are the available model relations: * @property UsersPhoneNumbers $phoneNumber */ class assignment extends CActiveRecord { /** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return assignment the static model class */ public static function model($className=__CLASS__) { return parent::model($className); } /** * @return string the associated database table name */ public function tableName() { return 'phone_number_group_assignment'; } /** * @return array validation rules for model attributes. */ public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( array('phone_number_id, group_id, created_date', 'required'), array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true), array('modified_date', 'safe'), // The following rule is used by search(). // Please remove those attributes that should not be searched. array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'), ); } /** * @return array relational rules. */ 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( 'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'), ); } /** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array( 'id' => 'ID', 'phone_number_id' => 'Phone Number', 'group_id' => 'Group', 'created_user' => 'Created User', 'created_date' => 'Created Date', 'modified_user' => 'Modified User', 'modified_date' => 'Modified Date', ); } /** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria=new CDbCriteria; $criteria->compare('id',$this->id); $criteria->compare('phone_number_id',$this->phone_number_id); $criteria->compare('group_id',$this->group_id); $criteria->compare('created_user',$this->created_user); $criteria->compare('created_date',$this->created_date,true); $criteria->compare('modified_user',$this->modified_user); $criteria->compare('modified_date',$this->modified_date,true); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, )); } },yii,Yii,我是yii框架的新手。我有3个表表表A、表B、表C。表A和表B与主键和外键关系相关。表B和表C与主键和外键关系链接的方式相同。我想在管理页面的cgridview中显示、筛选数据。使用yii fra /** * This is the model class for table "phone_number_group_assignment". * * The followings are the available column
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
更新:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
我有3个模型:subscriber.php、assignment.php、groups.php
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
/**
* This is the model class for table "client_groups".
*
* The followings are the available columns in table 'client_groups':
* @property integer $id
* @property integer $client_id
* @property string $title
* @property string $keywords
* @property integer $status
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
* @property integer $is_default
* @property integer $is_special_group
* @property string $back_office_no
* @property string $special_group_sms_text
* @property string $text_sms_office
* @property string $day_delay_1
* @property string $subscription_sms_1
* @property string $day_delay_2
* @property string $subscription_sms_2
* @property string $day_delay_3
* @property string $subscription_sms_3
* @property string $campaign_sms
* @property string $delay_time_1
* @property string $delay_time_2
* @property string $delay_time_3
* @property integer $msg_counter
* @property integer $msg_counter_start_num
* @property integer $add_expiry
* @property integer $add_days
* @property integer $phone_number_id
* @property integer $ar_type
* @property string $email
*
* The followings are the available model relations:
* @property ClientInformation $client
*/
class Groups extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Groups the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'client_groups';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('client_id, created_user, created_date, msg_counter, add_expiry, add_days, phone_number_id, ar_type, email', 'required'),
array('client_id, status, created_user, modified_user, is_default, is_special_group, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type', 'numerical', 'integerOnly'=>true),
array('title', 'length', 'max'=>250),
array('keywords', 'length', 'max'=>255),
array('back_office_no', 'length', 'max'=>50),
array('day_delay_1, day_delay_2, day_delay_3', 'length', 'max'=>3),
array('subscription_sms_1, subscription_sms_2, subscription_sms_3, campaign_sms, email', 'length', 'max'=>200),
array('modified_date, special_group_sms_text, text_sms_office, delay_time_1, delay_time_2, delay_time_3', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, client_id, title, keywords, status, created_user, created_date, modified_user, modified_date, is_default, is_special_group, back_office_no, special_group_sms_text, text_sms_office, day_delay_1, subscription_sms_1, day_delay_2, subscription_sms_2, day_delay_3, subscription_sms_3, campaign_sms, delay_time_1, delay_time_2, delay_time_3, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type, email', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'client' => array(self::BELONGS_TO, 'ClientInformation', 'client_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'client_id' => 'Client',
'title' => 'Title',
'keywords' => 'Keywords',
'status' => 'Status',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
'is_default' => 'Is Default',
'is_special_group' => 'Is Special Group',
'back_office_no' => 'Back Office No',
'special_group_sms_text' => 'Special Group Sms Text',
'text_sms_office' => 'Text Sms Office',
'day_delay_1' => 'Day Delay 1',
'subscription_sms_1' => 'Subscription Sms 1',
'day_delay_2' => 'Day Delay 2',
'subscription_sms_2' => 'Subscription Sms 2',
'day_delay_3' => 'Day Delay 3',
'subscription_sms_3' => 'Subscription Sms 3',
'campaign_sms' => 'Campaign Sms',
'delay_time_1' => 'Delay Time 1',
'delay_time_2' => 'Delay Time 2',
'delay_time_3' => 'Delay Time 3',
'msg_counter' => 'Msg Counter',
'msg_counter_start_num' => 'Msg Counter Start Num',
'add_expiry' => 'Add Expiry',
'add_days' => 'Add Days',
'phone_number_id' => 'Phone Number',
'ar_type' => 'Ar Type',
'email' => 'Email',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('client_id',$this->client_id);
$criteria->compare('title',$this->title,true);
$criteria->compare('keywords',$this->keywords,true);
$criteria->compare('status',$this->status);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
$criteria->compare('is_default',$this->is_default);
$criteria->compare('is_special_group',$this->is_special_group);
$criteria->compare('back_office_no',$this->back_office_no,true);
$criteria->compare('special_group_sms_text',$this->special_group_sms_text,true);
$criteria->compare('text_sms_office',$this->text_sms_office,true);
$criteria->compare('day_delay_1',$this->day_delay_1,true);
$criteria->compare('subscription_sms_1',$this->subscription_sms_1,true);
$criteria->compare('day_delay_2',$this->day_delay_2,true);
$criteria->compare('subscription_sms_2',$this->subscription_sms_2,true);
$criteria->compare('day_delay_3',$this->day_delay_3,true);
$criteria->compare('subscription_sms_3',$this->subscription_sms_3,true);
$criteria->compare('campaign_sms',$this->campaign_sms,true);
$criteria->compare('delay_time_1',$this->delay_time_1,true);
$criteria->compare('delay_time_2',$this->delay_time_2,true);
$criteria->compare('delay_time_3',$this->delay_time_3,true);
$criteria->compare('msg_counter',$this->msg_counter);
$criteria->compare('msg_counter_start_num',$this->msg_counter_start_num);
$criteria->compare('add_expiry',$this->add_expiry);
$criteria->compare('add_days',$this->add_days);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('ar_type',$this->ar_type);
$criteria->compare('email',$this->email,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
我想显示3个模型的属性,并在subscriber.php的cgridview中显示它们
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
/**
* This is the model class for table "client_groups".
*
* The followings are the available columns in table 'client_groups':
* @property integer $id
* @property integer $client_id
* @property string $title
* @property string $keywords
* @property integer $status
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
* @property integer $is_default
* @property integer $is_special_group
* @property string $back_office_no
* @property string $special_group_sms_text
* @property string $text_sms_office
* @property string $day_delay_1
* @property string $subscription_sms_1
* @property string $day_delay_2
* @property string $subscription_sms_2
* @property string $day_delay_3
* @property string $subscription_sms_3
* @property string $campaign_sms
* @property string $delay_time_1
* @property string $delay_time_2
* @property string $delay_time_3
* @property integer $msg_counter
* @property integer $msg_counter_start_num
* @property integer $add_expiry
* @property integer $add_days
* @property integer $phone_number_id
* @property integer $ar_type
* @property string $email
*
* The followings are the available model relations:
* @property ClientInformation $client
*/
class Groups extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Groups the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'client_groups';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('client_id, created_user, created_date, msg_counter, add_expiry, add_days, phone_number_id, ar_type, email', 'required'),
array('client_id, status, created_user, modified_user, is_default, is_special_group, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type', 'numerical', 'integerOnly'=>true),
array('title', 'length', 'max'=>250),
array('keywords', 'length', 'max'=>255),
array('back_office_no', 'length', 'max'=>50),
array('day_delay_1, day_delay_2, day_delay_3', 'length', 'max'=>3),
array('subscription_sms_1, subscription_sms_2, subscription_sms_3, campaign_sms, email', 'length', 'max'=>200),
array('modified_date, special_group_sms_text, text_sms_office, delay_time_1, delay_time_2, delay_time_3', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, client_id, title, keywords, status, created_user, created_date, modified_user, modified_date, is_default, is_special_group, back_office_no, special_group_sms_text, text_sms_office, day_delay_1, subscription_sms_1, day_delay_2, subscription_sms_2, day_delay_3, subscription_sms_3, campaign_sms, delay_time_1, delay_time_2, delay_time_3, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type, email', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'client' => array(self::BELONGS_TO, 'ClientInformation', 'client_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'client_id' => 'Client',
'title' => 'Title',
'keywords' => 'Keywords',
'status' => 'Status',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
'is_default' => 'Is Default',
'is_special_group' => 'Is Special Group',
'back_office_no' => 'Back Office No',
'special_group_sms_text' => 'Special Group Sms Text',
'text_sms_office' => 'Text Sms Office',
'day_delay_1' => 'Day Delay 1',
'subscription_sms_1' => 'Subscription Sms 1',
'day_delay_2' => 'Day Delay 2',
'subscription_sms_2' => 'Subscription Sms 2',
'day_delay_3' => 'Day Delay 3',
'subscription_sms_3' => 'Subscription Sms 3',
'campaign_sms' => 'Campaign Sms',
'delay_time_1' => 'Delay Time 1',
'delay_time_2' => 'Delay Time 2',
'delay_time_3' => 'Delay Time 3',
'msg_counter' => 'Msg Counter',
'msg_counter_start_num' => 'Msg Counter Start Num',
'add_expiry' => 'Add Expiry',
'add_days' => 'Add Days',
'phone_number_id' => 'Phone Number',
'ar_type' => 'Ar Type',
'email' => 'Email',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('client_id',$this->client_id);
$criteria->compare('title',$this->title,true);
$criteria->compare('keywords',$this->keywords,true);
$criteria->compare('status',$this->status);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
$criteria->compare('is_default',$this->is_default);
$criteria->compare('is_special_group',$this->is_special_group);
$criteria->compare('back_office_no',$this->back_office_no,true);
$criteria->compare('special_group_sms_text',$this->special_group_sms_text,true);
$criteria->compare('text_sms_office',$this->text_sms_office,true);
$criteria->compare('day_delay_1',$this->day_delay_1,true);
$criteria->compare('subscription_sms_1',$this->subscription_sms_1,true);
$criteria->compare('day_delay_2',$this->day_delay_2,true);
$criteria->compare('subscription_sms_2',$this->subscription_sms_2,true);
$criteria->compare('day_delay_3',$this->day_delay_3,true);
$criteria->compare('subscription_sms_3',$this->subscription_sms_3,true);
$criteria->compare('campaign_sms',$this->campaign_sms,true);
$criteria->compare('delay_time_1',$this->delay_time_1,true);
$criteria->compare('delay_time_2',$this->delay_time_2,true);
$criteria->compare('delay_time_3',$this->delay_time_3,true);
$criteria->compare('msg_counter',$this->msg_counter);
$criteria->compare('msg_counter_start_num',$this->msg_counter_start_num);
$criteria->compare('add_expiry',$this->add_expiry);
$criteria->compare('add_days',$this->add_days);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('ar_type',$this->ar_type);
$criteria->compare('email',$this->email,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
subscriber.php。。。。。。。。。。
/**
* This is the model class for table "users_phone_numbers".
*
* The followings are the available columns in table 'users_phone_numbers':
* @property integer $id
* @property string $name
* @property string $phone_number
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
* @property integer $status
* @property string $message_type
* @property string $birthdate
* @property string $email
*
* The followings are the available model relations:
* @property PhoneNumberGroupAssignment[] $phoneNumberGroupAssignments
*/
class subscriber extends CActiveRecord
{
//public $group_search; //for searching and displaying in cgridview
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return subscriber the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'users_phone_numbers';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number, created_user, created_date, birthdate, email', 'required'),
array('created_user, modified_user, status', 'numerical', 'integerOnly'=>true),
array('name, phone_number', 'length', 'max'=>100),
array('message_type', 'length', 'max'=>20),
array('email', 'length', 'max'=>150),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, name, phone_number, created_user, created_date, modified_user, modified_date, status, message_type, birthdate, email ', 'safe', 'on'=>'search'),//add above defined variable.
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumberGroupAssignments' => array(self::HAS_MANY, 'Assignment', 'phone_number_id'),
//'postCount' => array(self::STAT, 'assignment', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'name' => 'Name',
'phone_number' => 'Phone Number',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
'status' => 'Status',
'message_type' => 'Message Type',
'birthdate' => 'Birthdate',
'email' => 'Email',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
//$criteria->with = array( 'phoneNumberGroupAssignments' ); //new
$criteria->compare('id',$this->id);
$criteria->compare('name',$this->name,true);
$criteria->compare('phone_number',$this->phone_number,true);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
$criteria->compare('status',$this->status);
$criteria->compare('message_type',$this->message_type,true);
$criteria->compare('birthdate',$this->birthdate,true);
$criteria->compare('email',$this->email,true);
//$criteria->compare( 'phoneNumberGroupAssignments.group_id', $this->group_search, true );
return new CActiveDataProvider($this, array('criteria'=>$criteria,
/*'sort'=>array(
'attributes'=>array(
'group_search'=>array(
'asc'=>'phoneNumberGroupAssignments.group_id',
'desc'=>'phoneNumberGroupAssignments.group_id DESC',
),
),
),
*/
));
}
}
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
/**
* This is the model class for table "client_groups".
*
* The followings are the available columns in table 'client_groups':
* @property integer $id
* @property integer $client_id
* @property string $title
* @property string $keywords
* @property integer $status
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
* @property integer $is_default
* @property integer $is_special_group
* @property string $back_office_no
* @property string $special_group_sms_text
* @property string $text_sms_office
* @property string $day_delay_1
* @property string $subscription_sms_1
* @property string $day_delay_2
* @property string $subscription_sms_2
* @property string $day_delay_3
* @property string $subscription_sms_3
* @property string $campaign_sms
* @property string $delay_time_1
* @property string $delay_time_2
* @property string $delay_time_3
* @property integer $msg_counter
* @property integer $msg_counter_start_num
* @property integer $add_expiry
* @property integer $add_days
* @property integer $phone_number_id
* @property integer $ar_type
* @property string $email
*
* The followings are the available model relations:
* @property ClientInformation $client
*/
class Groups extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Groups the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'client_groups';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('client_id, created_user, created_date, msg_counter, add_expiry, add_days, phone_number_id, ar_type, email', 'required'),
array('client_id, status, created_user, modified_user, is_default, is_special_group, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type', 'numerical', 'integerOnly'=>true),
array('title', 'length', 'max'=>250),
array('keywords', 'length', 'max'=>255),
array('back_office_no', 'length', 'max'=>50),
array('day_delay_1, day_delay_2, day_delay_3', 'length', 'max'=>3),
array('subscription_sms_1, subscription_sms_2, subscription_sms_3, campaign_sms, email', 'length', 'max'=>200),
array('modified_date, special_group_sms_text, text_sms_office, delay_time_1, delay_time_2, delay_time_3', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, client_id, title, keywords, status, created_user, created_date, modified_user, modified_date, is_default, is_special_group, back_office_no, special_group_sms_text, text_sms_office, day_delay_1, subscription_sms_1, day_delay_2, subscription_sms_2, day_delay_3, subscription_sms_3, campaign_sms, delay_time_1, delay_time_2, delay_time_3, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type, email', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'client' => array(self::BELONGS_TO, 'ClientInformation', 'client_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'client_id' => 'Client',
'title' => 'Title',
'keywords' => 'Keywords',
'status' => 'Status',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
'is_default' => 'Is Default',
'is_special_group' => 'Is Special Group',
'back_office_no' => 'Back Office No',
'special_group_sms_text' => 'Special Group Sms Text',
'text_sms_office' => 'Text Sms Office',
'day_delay_1' => 'Day Delay 1',
'subscription_sms_1' => 'Subscription Sms 1',
'day_delay_2' => 'Day Delay 2',
'subscription_sms_2' => 'Subscription Sms 2',
'day_delay_3' => 'Day Delay 3',
'subscription_sms_3' => 'Subscription Sms 3',
'campaign_sms' => 'Campaign Sms',
'delay_time_1' => 'Delay Time 1',
'delay_time_2' => 'Delay Time 2',
'delay_time_3' => 'Delay Time 3',
'msg_counter' => 'Msg Counter',
'msg_counter_start_num' => 'Msg Counter Start Num',
'add_expiry' => 'Add Expiry',
'add_days' => 'Add Days',
'phone_number_id' => 'Phone Number',
'ar_type' => 'Ar Type',
'email' => 'Email',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('client_id',$this->client_id);
$criteria->compare('title',$this->title,true);
$criteria->compare('keywords',$this->keywords,true);
$criteria->compare('status',$this->status);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
$criteria->compare('is_default',$this->is_default);
$criteria->compare('is_special_group',$this->is_special_group);
$criteria->compare('back_office_no',$this->back_office_no,true);
$criteria->compare('special_group_sms_text',$this->special_group_sms_text,true);
$criteria->compare('text_sms_office',$this->text_sms_office,true);
$criteria->compare('day_delay_1',$this->day_delay_1,true);
$criteria->compare('subscription_sms_1',$this->subscription_sms_1,true);
$criteria->compare('day_delay_2',$this->day_delay_2,true);
$criteria->compare('subscription_sms_2',$this->subscription_sms_2,true);
$criteria->compare('day_delay_3',$this->day_delay_3,true);
$criteria->compare('subscription_sms_3',$this->subscription_sms_3,true);
$criteria->compare('campaign_sms',$this->campaign_sms,true);
$criteria->compare('delay_time_1',$this->delay_time_1,true);
$criteria->compare('delay_time_2',$this->delay_time_2,true);
$criteria->compare('delay_time_3',$this->delay_time_3,true);
$criteria->compare('msg_counter',$this->msg_counter);
$criteria->compare('msg_counter_start_num',$this->msg_counter_start_num);
$criteria->compare('add_expiry',$this->add_expiry);
$criteria->compare('add_days',$this->add_days);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('ar_type',$this->ar_type);
$criteria->compare('email',$this->email,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
第二次作业.php
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
/**
* This is the model class for table "client_groups".
*
* The followings are the available columns in table 'client_groups':
* @property integer $id
* @property integer $client_id
* @property string $title
* @property string $keywords
* @property integer $status
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
* @property integer $is_default
* @property integer $is_special_group
* @property string $back_office_no
* @property string $special_group_sms_text
* @property string $text_sms_office
* @property string $day_delay_1
* @property string $subscription_sms_1
* @property string $day_delay_2
* @property string $subscription_sms_2
* @property string $day_delay_3
* @property string $subscription_sms_3
* @property string $campaign_sms
* @property string $delay_time_1
* @property string $delay_time_2
* @property string $delay_time_3
* @property integer $msg_counter
* @property integer $msg_counter_start_num
* @property integer $add_expiry
* @property integer $add_days
* @property integer $phone_number_id
* @property integer $ar_type
* @property string $email
*
* The followings are the available model relations:
* @property ClientInformation $client
*/
class Groups extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Groups the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'client_groups';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('client_id, created_user, created_date, msg_counter, add_expiry, add_days, phone_number_id, ar_type, email', 'required'),
array('client_id, status, created_user, modified_user, is_default, is_special_group, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type', 'numerical', 'integerOnly'=>true),
array('title', 'length', 'max'=>250),
array('keywords', 'length', 'max'=>255),
array('back_office_no', 'length', 'max'=>50),
array('day_delay_1, day_delay_2, day_delay_3', 'length', 'max'=>3),
array('subscription_sms_1, subscription_sms_2, subscription_sms_3, campaign_sms, email', 'length', 'max'=>200),
array('modified_date, special_group_sms_text, text_sms_office, delay_time_1, delay_time_2, delay_time_3', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, client_id, title, keywords, status, created_user, created_date, modified_user, modified_date, is_default, is_special_group, back_office_no, special_group_sms_text, text_sms_office, day_delay_1, subscription_sms_1, day_delay_2, subscription_sms_2, day_delay_3, subscription_sms_3, campaign_sms, delay_time_1, delay_time_2, delay_time_3, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type, email', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'client' => array(self::BELONGS_TO, 'ClientInformation', 'client_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'client_id' => 'Client',
'title' => 'Title',
'keywords' => 'Keywords',
'status' => 'Status',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
'is_default' => 'Is Default',
'is_special_group' => 'Is Special Group',
'back_office_no' => 'Back Office No',
'special_group_sms_text' => 'Special Group Sms Text',
'text_sms_office' => 'Text Sms Office',
'day_delay_1' => 'Day Delay 1',
'subscription_sms_1' => 'Subscription Sms 1',
'day_delay_2' => 'Day Delay 2',
'subscription_sms_2' => 'Subscription Sms 2',
'day_delay_3' => 'Day Delay 3',
'subscription_sms_3' => 'Subscription Sms 3',
'campaign_sms' => 'Campaign Sms',
'delay_time_1' => 'Delay Time 1',
'delay_time_2' => 'Delay Time 2',
'delay_time_3' => 'Delay Time 3',
'msg_counter' => 'Msg Counter',
'msg_counter_start_num' => 'Msg Counter Start Num',
'add_expiry' => 'Add Expiry',
'add_days' => 'Add Days',
'phone_number_id' => 'Phone Number',
'ar_type' => 'Ar Type',
'email' => 'Email',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('client_id',$this->client_id);
$criteria->compare('title',$this->title,true);
$criteria->compare('keywords',$this->keywords,true);
$criteria->compare('status',$this->status);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
$criteria->compare('is_default',$this->is_default);
$criteria->compare('is_special_group',$this->is_special_group);
$criteria->compare('back_office_no',$this->back_office_no,true);
$criteria->compare('special_group_sms_text',$this->special_group_sms_text,true);
$criteria->compare('text_sms_office',$this->text_sms_office,true);
$criteria->compare('day_delay_1',$this->day_delay_1,true);
$criteria->compare('subscription_sms_1',$this->subscription_sms_1,true);
$criteria->compare('day_delay_2',$this->day_delay_2,true);
$criteria->compare('subscription_sms_2',$this->subscription_sms_2,true);
$criteria->compare('day_delay_3',$this->day_delay_3,true);
$criteria->compare('subscription_sms_3',$this->subscription_sms_3,true);
$criteria->compare('campaign_sms',$this->campaign_sms,true);
$criteria->compare('delay_time_1',$this->delay_time_1,true);
$criteria->compare('delay_time_2',$this->delay_time_2,true);
$criteria->compare('delay_time_3',$this->delay_time_3,true);
$criteria->compare('msg_counter',$this->msg_counter);
$criteria->compare('msg_counter_start_num',$this->msg_counter_start_num);
$criteria->compare('add_expiry',$this->add_expiry);
$criteria->compare('add_days',$this->add_days);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('ar_type',$this->ar_type);
$criteria->compare('email',$this->email,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
第三个:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
groups.php
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
/**
* This is the model class for table "client_groups".
*
* The followings are the available columns in table 'client_groups':
* @property integer $id
* @property integer $client_id
* @property string $title
* @property string $keywords
* @property integer $status
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
* @property integer $is_default
* @property integer $is_special_group
* @property string $back_office_no
* @property string $special_group_sms_text
* @property string $text_sms_office
* @property string $day_delay_1
* @property string $subscription_sms_1
* @property string $day_delay_2
* @property string $subscription_sms_2
* @property string $day_delay_3
* @property string $subscription_sms_3
* @property string $campaign_sms
* @property string $delay_time_1
* @property string $delay_time_2
* @property string $delay_time_3
* @property integer $msg_counter
* @property integer $msg_counter_start_num
* @property integer $add_expiry
* @property integer $add_days
* @property integer $phone_number_id
* @property integer $ar_type
* @property string $email
*
* The followings are the available model relations:
* @property ClientInformation $client
*/
class Groups extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Groups the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'client_groups';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('client_id, created_user, created_date, msg_counter, add_expiry, add_days, phone_number_id, ar_type, email', 'required'),
array('client_id, status, created_user, modified_user, is_default, is_special_group, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type', 'numerical', 'integerOnly'=>true),
array('title', 'length', 'max'=>250),
array('keywords', 'length', 'max'=>255),
array('back_office_no', 'length', 'max'=>50),
array('day_delay_1, day_delay_2, day_delay_3', 'length', 'max'=>3),
array('subscription_sms_1, subscription_sms_2, subscription_sms_3, campaign_sms, email', 'length', 'max'=>200),
array('modified_date, special_group_sms_text, text_sms_office, delay_time_1, delay_time_2, delay_time_3', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, client_id, title, keywords, status, created_user, created_date, modified_user, modified_date, is_default, is_special_group, back_office_no, special_group_sms_text, text_sms_office, day_delay_1, subscription_sms_1, day_delay_2, subscription_sms_2, day_delay_3, subscription_sms_3, campaign_sms, delay_time_1, delay_time_2, delay_time_3, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type, email', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'client' => array(self::BELONGS_TO, 'ClientInformation', 'client_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'client_id' => 'Client',
'title' => 'Title',
'keywords' => 'Keywords',
'status' => 'Status',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
'is_default' => 'Is Default',
'is_special_group' => 'Is Special Group',
'back_office_no' => 'Back Office No',
'special_group_sms_text' => 'Special Group Sms Text',
'text_sms_office' => 'Text Sms Office',
'day_delay_1' => 'Day Delay 1',
'subscription_sms_1' => 'Subscription Sms 1',
'day_delay_2' => 'Day Delay 2',
'subscription_sms_2' => 'Subscription Sms 2',
'day_delay_3' => 'Day Delay 3',
'subscription_sms_3' => 'Subscription Sms 3',
'campaign_sms' => 'Campaign Sms',
'delay_time_1' => 'Delay Time 1',
'delay_time_2' => 'Delay Time 2',
'delay_time_3' => 'Delay Time 3',
'msg_counter' => 'Msg Counter',
'msg_counter_start_num' => 'Msg Counter Start Num',
'add_expiry' => 'Add Expiry',
'add_days' => 'Add Days',
'phone_number_id' => 'Phone Number',
'ar_type' => 'Ar Type',
'email' => 'Email',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('client_id',$this->client_id);
$criteria->compare('title',$this->title,true);
$criteria->compare('keywords',$this->keywords,true);
$criteria->compare('status',$this->status);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
$criteria->compare('is_default',$this->is_default);
$criteria->compare('is_special_group',$this->is_special_group);
$criteria->compare('back_office_no',$this->back_office_no,true);
$criteria->compare('special_group_sms_text',$this->special_group_sms_text,true);
$criteria->compare('text_sms_office',$this->text_sms_office,true);
$criteria->compare('day_delay_1',$this->day_delay_1,true);
$criteria->compare('subscription_sms_1',$this->subscription_sms_1,true);
$criteria->compare('day_delay_2',$this->day_delay_2,true);
$criteria->compare('subscription_sms_2',$this->subscription_sms_2,true);
$criteria->compare('day_delay_3',$this->day_delay_3,true);
$criteria->compare('subscription_sms_3',$this->subscription_sms_3,true);
$criteria->compare('campaign_sms',$this->campaign_sms,true);
$criteria->compare('delay_time_1',$this->delay_time_1,true);
$criteria->compare('delay_time_2',$this->delay_time_2,true);
$criteria->compare('delay_time_3',$this->delay_time_3,true);
$criteria->compare('msg_counter',$this->msg_counter);
$criteria->compare('msg_counter_start_num',$this->msg_counter_start_num);
$criteria->compare('add_expiry',$this->add_expiry);
$criteria->compare('add_days',$this->add_days);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('ar_type',$this->ar_type);
$criteria->compare('email',$this->email,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
当前的cgrid视图正在访问来自两个模型的数据,assignemnt和subscriber,但不访问来自组的数据。在尝试获取非对象的属性时,会出现错误
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
C:\wamp\www\yii\framework\base\CComponent.php(607):eval()d代码(1)
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
/**
* This is the model class for table "client_groups".
*
* The followings are the available columns in table 'client_groups':
* @property integer $id
* @property integer $client_id
* @property string $title
* @property string $keywords
* @property integer $status
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
* @property integer $is_default
* @property integer $is_special_group
* @property string $back_office_no
* @property string $special_group_sms_text
* @property string $text_sms_office
* @property string $day_delay_1
* @property string $subscription_sms_1
* @property string $day_delay_2
* @property string $subscription_sms_2
* @property string $day_delay_3
* @property string $subscription_sms_3
* @property string $campaign_sms
* @property string $delay_time_1
* @property string $delay_time_2
* @property string $delay_time_3
* @property integer $msg_counter
* @property integer $msg_counter_start_num
* @property integer $add_expiry
* @property integer $add_days
* @property integer $phone_number_id
* @property integer $ar_type
* @property string $email
*
* The followings are the available model relations:
* @property ClientInformation $client
*/
class Groups extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Groups the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'client_groups';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('client_id, created_user, created_date, msg_counter, add_expiry, add_days, phone_number_id, ar_type, email', 'required'),
array('client_id, status, created_user, modified_user, is_default, is_special_group, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type', 'numerical', 'integerOnly'=>true),
array('title', 'length', 'max'=>250),
array('keywords', 'length', 'max'=>255),
array('back_office_no', 'length', 'max'=>50),
array('day_delay_1, day_delay_2, day_delay_3', 'length', 'max'=>3),
array('subscription_sms_1, subscription_sms_2, subscription_sms_3, campaign_sms, email', 'length', 'max'=>200),
array('modified_date, special_group_sms_text, text_sms_office, delay_time_1, delay_time_2, delay_time_3', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, client_id, title, keywords, status, created_user, created_date, modified_user, modified_date, is_default, is_special_group, back_office_no, special_group_sms_text, text_sms_office, day_delay_1, subscription_sms_1, day_delay_2, subscription_sms_2, day_delay_3, subscription_sms_3, campaign_sms, delay_time_1, delay_time_2, delay_time_3, msg_counter, msg_counter_start_num, add_expiry, add_days, phone_number_id, ar_type, email', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'client' => array(self::BELONGS_TO, 'ClientInformation', 'client_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'client_id' => 'Client',
'title' => 'Title',
'keywords' => 'Keywords',
'status' => 'Status',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
'is_default' => 'Is Default',
'is_special_group' => 'Is Special Group',
'back_office_no' => 'Back Office No',
'special_group_sms_text' => 'Special Group Sms Text',
'text_sms_office' => 'Text Sms Office',
'day_delay_1' => 'Day Delay 1',
'subscription_sms_1' => 'Subscription Sms 1',
'day_delay_2' => 'Day Delay 2',
'subscription_sms_2' => 'Subscription Sms 2',
'day_delay_3' => 'Day Delay 3',
'subscription_sms_3' => 'Subscription Sms 3',
'campaign_sms' => 'Campaign Sms',
'delay_time_1' => 'Delay Time 1',
'delay_time_2' => 'Delay Time 2',
'delay_time_3' => 'Delay Time 3',
'msg_counter' => 'Msg Counter',
'msg_counter_start_num' => 'Msg Counter Start Num',
'add_expiry' => 'Add Expiry',
'add_days' => 'Add Days',
'phone_number_id' => 'Phone Number',
'ar_type' => 'Ar Type',
'email' => 'Email',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('client_id',$this->client_id);
$criteria->compare('title',$this->title,true);
$criteria->compare('keywords',$this->keywords,true);
$criteria->compare('status',$this->status);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
$criteria->compare('is_default',$this->is_default);
$criteria->compare('is_special_group',$this->is_special_group);
$criteria->compare('back_office_no',$this->back_office_no,true);
$criteria->compare('special_group_sms_text',$this->special_group_sms_text,true);
$criteria->compare('text_sms_office',$this->text_sms_office,true);
$criteria->compare('day_delay_1',$this->day_delay_1,true);
$criteria->compare('subscription_sms_1',$this->subscription_sms_1,true);
$criteria->compare('day_delay_2',$this->day_delay_2,true);
$criteria->compare('subscription_sms_2',$this->subscription_sms_2,true);
$criteria->compare('day_delay_3',$this->day_delay_3,true);
$criteria->compare('subscription_sms_3',$this->subscription_sms_3,true);
$criteria->compare('campaign_sms',$this->campaign_sms,true);
$criteria->compare('delay_time_1',$this->delay_time_1,true);
$criteria->compare('delay_time_2',$this->delay_time_2,true);
$criteria->compare('delay_time_3',$this->delay_time_3,true);
$criteria->compare('msg_counter',$this->msg_counter);
$criteria->compare('msg_counter_start_num',$this->msg_counter_start_num);
$criteria->compare('add_expiry',$this->add_expiry);
$criteria->compare('add_days',$this->add_days);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('ar_type',$this->ar_type);
$criteria->compare('email',$this->email,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
…那么请检查2个,然后检查3个型号?需要紧急帮助。感谢表A的“管理员”视图。您应该能够通过在列定义中这样列出其他值来访问这些值:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
'columns'=>array(
array('name'=>'column heading 1','value'=>'$data->modelB_nameinA->col_name1'),
array('name'=>'column heading 2','value'=>'$data->modelB_nameinA->C->col_name2'),
要筛选这些值,您需要能够在modelA->search()函数中访问它们。我发现最简单的方法是在a中为要从B和C中显示的每个列名称显式设置一个公共值。您还需要将它们包含在modelA->rules()中的安全搜索语句中,为了简单起见,还需要将它们包含在modelA->attributeLabels()中。您可能还必须在A的关系中包含C,因此modelA类的外观如下所示:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
class A extends CActiveRecord
{
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
...
// Please remove those attributes that should not be searched.
array('Col1_fromA, Col2_fromA, Col1_fromB, Col1_fromC', 'safe', 'on'=>'search'),
);
}
/**
* Put here the names of the columns from B and C that you are wanting to filter on
*/
public $Col1_fromB;
public $Col1_fromC;
/**
* @return array relational rules.
*/
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(
'modelB_nameinA' => array(self::HAS_MANY, 'B', 'B_id'),
'modelC_nameinA' => array(self::HAS_MANY, 'C', array('C_id'=>'id'),'through'=>'B'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'Col1_fromA' => 'Fancy name for Col1_fromA',
'Col2_fromA' => 'Fancy name for Col2_fromA',
'Col1_fromB' => 'Fancy name for Col1_fromB',
'Col1_fromC' => 'Fancy name for Col1_fromC',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
// this is so those two tables are included in the SQL generated:
$criteria->with = array( 'B', 'C' );
$criteria->together=true;
$criteria->compare('Col1_fromA',$this->Col1_fromA,true);
$criteria->compare('Col2_fromA',$this->Col2_fromA,true);
$criteria->compare('modelB_nameinA.Col1', $this->Col1_fromB,true);
$criteria->compare('modelC_nameinA.Col1', $this->Col1_fromC,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
...
这样做的一个优点是,您现在可以使用Col1_fromB和Col1_fromC作为cgridview中列定义中的名称值,您将获得在modelA定义中输入的奇特名称作为列标题。您需要在表A和表B中定义关系,才能从表A中获取模型C。
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
表A关系:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
public function relations() {
return array(
'tableB'=>array(self::HAS_ONE, 'TableB', 'tablea_id'),
);
}
public function relations() {
return array(
'tableC'=>array(self::HAS_ONE, 'TableC', 'tableb_id'),
);
}
表B关系:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
public function relations() {
return array(
'tableB'=>array(self::HAS_ONE, 'TableB', 'tablea_id'),
);
}
public function relations() {
return array(
'tableC'=>array(self::HAS_ONE, 'TableC', 'tableb_id'),
);
}
因此,您可以访问与tableA相关的tableB和tableC模型:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
$modelB = $tableA->tableB;
$modelC = $tableA->tableB->tableC;
您可以阅读有关关系活动记录的内容
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
在控制器操作中,获取模型:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
public function actionGrid() {
$model = new ModelA('search');
$model->unsetAttributes();
$this->render('view', array('model'=>$model));
}
使用CGridView查看和查看代码:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'grid',
'dataProvider'=>$model->search(),
'filter' => $model,
'ajaxUpdate'=>false,
'selectableRows'=>'10',
'columns'=>array(
array(
'id'=>'checkBoxId',
'class'=>'CCheckBoxColumn',
),
array(
'class'=>'CDataColumn',
'name'=>'modelA_attrib1',
'value'=>'$data->attrib1',
'sortable'=>true,
'filter'=>true,
),
array(
'class'=>'CDataColumn',
'name'=>'modelB_attrib1',
'value'=>'$data->modelB->attrib1',
'sortable'=>true,
'filter'=>true,
),
array(
'class'=>'CDataColumn',
'name'=>'modelC_attrib1',
'value'=>'$data->modelB->modelC->attrib1',
'sortable'=>true,
'filter'=>true,
),
...
更新: /**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
如果我理解正确,您在用户\u电话号码
和客户组
表中有许多关系(组可能与许多电话号码相关,号码指许多组)。
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
因此,phone\u number\u group\u assignment
(通常称为phone\u number\u group
)必须包含两个主键:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
* @property integer $phone_number_id
* @property integer $group_id
以及订户的关系
:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
public function relations()
{
return array(
'groups' => array(self::MANY_MANY, 'Groups', 'phone_number_group_assignment(phone_number_id, group_id)'),
);
}
组的关系
:
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
public function relations()
{
return array(
'phone_numbers' => array(self::MANY_MANY, 'Subscriber', 'phone_number_group_assignment(group_id, phone_number_id)'),
);
}
所以您可以从订阅服务器访问组:
$subscriber->groups
在数据库中创建一个视图,并在连接操作后放置所有需要的列,然后创建模型。
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
正如@user181452所说,我总是使用它,创建一个视图,然后生成一个模型。另一种方法是,在目标模型中,将每个新属性与模型中的公共变量绑定
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}
class NewModel {
public $new_attribute;
}
然后您可以从视图访问它。你必须为你的项目选择最干净的方式,因为如果你有一个复杂的连接,那么创建一个视图会更好。谢谢你的驱动程序,请看我的新问题和3个模型的代码片段…谢谢
/**
* This is the model class for table "phone_number_group_assignment".
*
* The followings are the available columns in table 'phone_number_group_assignment':
* @property integer $id
* @property integer $phone_number_id
* @property integer $group_id
* @property integer $created_user
* @property string $created_date
* @property integer $modified_user
* @property string $modified_date
*
* The followings are the available model relations:
* @property UsersPhoneNumbers $phoneNumber
*/
class assignment extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return assignment the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'phone_number_group_assignment';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('phone_number_id, group_id, created_date', 'required'),
array('phone_number_id, group_id, created_user, modified_user', 'numerical', 'integerOnly'=>true),
array('modified_date', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, phone_number_id, group_id, created_user, created_date, modified_user, modified_date', 'safe', 'on'=>'search'),
);
}
/**
* @return array relational rules.
*/
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(
'phoneNumber' => array(self::BELONGS_TO, 'Subscriber', 'phone_number_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'phone_number_id' => 'Phone Number',
'group_id' => 'Group',
'created_user' => 'Created User',
'created_date' => 'Created Date',
'modified_user' => 'Modified User',
'modified_date' => 'Modified Date',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('phone_number_id',$this->phone_number_id);
$criteria->compare('group_id',$this->group_id);
$criteria->compare('created_user',$this->created_user);
$criteria->compare('created_date',$this->created_date,true);
$criteria->compare('modified_user',$this->modified_user);
$criteria->compare('modified_date',$this->modified_date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}