<?php

/**
 * This is the model class for table "{{bases_encuestas}}".
 *
 * The followings are the available columns in table '{{bases_encuestas}}':
 * @property integer $id_encuesta_base
 * @property string $encuesta
 * @property string $autor
 * @property string $alcance
 * @property string $citacion
 * @property string $licencia_uso
 * @property string $enlace_original
 * @property string $resumen
 * @property string $fecha
 * @property string $otros
 * @property integer $descargable
 * @property integer $activo
 *
 * The followings are the available model relations:
 * @property BasesArchivos[] $basesArchivoses
 * @property BasesCategorias[] $basesCategoriases
 * @property BasesPreguntas[] $basesPreguntases
 */
class BasesEncuestas extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return BasesEncuestas 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 '{{bases_encuestas}}';
	}

	/**
	 * @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('encuesta', 'required'),
			array('graficable, descargable, activo, vistas', 'numerical', 'integerOnly'=>true),
			array('encuesta', 'length', 'max'=>150),
			array('autor, enlace_original, otros', 'length', 'max'=>255),
			array('alcance, citacion, licencia_uso, resumen, fecha, log', 'safe'),
			array('tabla', 'length', 'max'=>100),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id_encuesta_base, encuesta, autor, alcance, citacion, licencia_uso, enlace_original, resumen, fecha, otros, graficable, descargable, activo', '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(
			'basesArchivoses' => array(self::HAS_MANY, 'BasesArchivos', 'id_base_encuesta'),
			'basesCategoriases' => array(self::HAS_MANY, 'BasesCategorias', 'id_base_encuesta'),
			'basesPreguntases' => array(self::HAS_MANY, 'BasesPreguntas', 'id_base_encuesta'),
			'basesAutores' => array(self::HAS_MANY, 'BasesAutores', 'id_base_encuesta'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_encuesta_base' => 'Id Encuesta Base',
			'encuesta' => 'Encuesta',
			'autor' => 'Autor',
			'alcance' => 'Alcance',
			'citacion' => 'Citacion',
			'licencia_uso' => 'Licencia Uso',
			'enlace_original' => 'Enlace Original',
			'resumen' => 'Resumen',
			'fecha' => 'Fecha',
			'otros' => 'Otros',
			'descargable' => 'Descargable',
			'graficable' => 'graficable',
			'activo' => 'Activo',
			'vistas' => 'Vistas',
			'log' => 'Log',
		);
	}

	/**
	 * 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_encuesta_base',$this->id_encuesta_base);
		$criteria->compare('encuesta',$this->encuesta,true);
		$criteria->compare('autor',$this->autor,true);
		$criteria->compare('alcance',$this->alcance,true);
		$criteria->compare('citacion',$this->citacion,true);
		$criteria->compare('licencia_uso',$this->licencia_uso,true);
		$criteria->compare('enlace_original',$this->enlace_original,true);
		$criteria->compare('resumen',$this->resumen,true);
		$criteria->compare('fecha',$this->fecha,true);
		$criteria->compare('otros',$this->otros,true);
		$criteria->compare('descargable',$this->descargable);
		$criteria->compare('activo',$this->activo);

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