<?php

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

	/**
	 * @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('sys_m_module_id, sys_m_controller_id, action', 'required'),
			array('sys_m_module_id, sys_m_controller_id, action, name', 'length', 'max'=>100),
			array('ucrea, uupd', 'length', 'max'=>70),
			array('icrea, iupd', 'length', 'max'=>45),
			array('desc, dcrea, dupd', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('sys_m_privilage_id, sys_m_module_id, sys_m_controller_id, action, name, desc, 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_m_privilage_id' => 'Sys M Privilage',
			'sys_m_module_id' => 'Sys M Module',
			'sys_m_controller_id' => 'Sys M Controller',
			'action' => 'Action',
			'name' => 'Name',
			'desc' => 'Desc',
			'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_m_privilage_id',$this->sys_m_privilage_id);
		$criteria->compare('sys_m_module_id',$this->sys_m_module_id,true);
		$criteria->compare('sys_m_controller_id',$this->sys_m_controller_id,true);
		$criteria->compare('action',$this->action,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('desc',$this->desc,true);
		$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,
		));
	}
}