<?php

/**
 * This is the model class for table "sys_x_user_role".
 *
 * The followings are the available columns in table 'sys_x_user_role':
 * @property integer $sys_x_user_role_id
 * @property integer $user_id
 * @property integer $sys_m_role_id
 * @property string $ucrea
 * @property string $dcrea
 * @property string $icrea
 * @property string $uupd
 * @property string $dupd
 * @property string $iupd
 */
class UserRole extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return UserRole 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 'sys_x_user_role';
	}

	/**
	 * @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('user_id, sys_m_role_id', 'required'),
			array('user_id, sys_m_role_id', 'numerical', 'integerOnly'=>true),
			array('ucrea, uupd', 'length', 'max'=>70),
			array('icrea, iupd', 'length', 'max'=>45),
			array('dcrea, dupd', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('sys_x_user_role_id, user_id, sys_m_role_id, ucrea, dcrea, icrea, uupd, dupd, iupd', '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(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'sys_x_user_role_id' => 'Sys X User Role',
			'user_id' => 'User',
			'sys_m_role_id' => 'Sys M Role',
			'ucrea' => 'Ucrea',
			'dcrea' => 'Dcrea',
			'icrea' => 'Icrea',
			'uupd' => 'Uupd',
			'dupd' => 'Dupd',
			'iupd' => 'Iupd',
		);
	}

	/**
	 * 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('sys_x_user_role_id',$this->sys_x_user_role_id);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('sys_m_role_id',$this->sys_m_role_id);
		$criteria->compare('ucrea',$this->ucrea,true);
		$criteria->compare('dcrea',$this->dcrea,true);
		$criteria->compare('icrea',$this->icrea,true);
		$criteria->compare('uupd',$this->uupd,true);
		$criteria->compare('dupd',$this->dupd,true);
		$criteria->compare('iupd',$this->iupd,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}