Все модель
<?php
/**
* This is the model class for table "users".
*
* The followings are the available columns in table 'users':
* @property integer $id_users
* @property integer $is_active_user
* @property integer $is_staff
* @property string $role
* @property string $created_user
* @property string $update_user
* @property string $last_login
* @property string $email
* @property string $uid
* @property string $first_name
* @property string $photo
* @property string $photo_rec
* @property string $session
* @property string $hash
*/
class Users extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'users';
}
/**
* @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('created_user, uid, first_name, hash', 'required', 'message'=>'Введите значение {attribute}.'),
array('is_active_user, is_staff', 'numerical', 'integerOnly'=>true),
array('role', 'length', 'max'=>20),
array('email', 'length', 'max'=>50),
array('uid, first_name, photo, photo_rec, session, hash', 'length', 'max'=>255),
array('update_user, last_login', 'safe'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id_users, is_active_user, is_staff, role, created_user, update_user, last_login, email, uid, first_name, photo, photo_rec, session, hash', '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(
'profile'=>array(self::HAS_ONE, 'UserProfile', 'id_user'),
'info'=>array(self::HAS_ONE, 'UsersRating', 'id_user',
'select'=>'*',
'joinType'=>'LEFT JOIN',
'join'=>'LEFT JOIN `user_status` ON `info`.`rating` > `user_status`.`rating_min` AND `info`.`rating` < `user_status`.`rating_max`',
),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id_users' => 'Id Users',
'is_active_user' => 'Is Active User',
'is_staff' => 'Is Staff',
'role' => 'Role',
'created_user' => 'Created User',
'update_user' => 'Update User',
'last_login' => 'Last Login',
'email' => 'Email',
'uid' => 'Uid',
'first_name' => 'First Name',
'photo' => 'Photo',
'photo_rec' => 'Photo Rec',
'session' => 'Session',
'hash' => 'Hash',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id_users',$this->id_users);
$criteria->compare('is_active_user',$this->is_active_user);
$criteria->compare('is_staff',$this->is_staff);
$criteria->compare('role',$this->role,true);
$criteria->compare('created_user',$this->created_user,true);
$criteria->compare('update_user',$this->update_user,true);
$criteria->compare('last_login',$this->last_login,true);
$criteria->compare('email',$this->email,true);
$criteria->compare('uid',$this->uid,true);
$criteria->compare('first_name',$this->first_name,true);
$criteria->compare('photo',$this->photo,true);
$criteria->compare('photo_rec',$this->photo_rec,true);
$criteria->compare('session',$this->session,true);
$criteria->compare('hash',$this->hash,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return Users the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}