yiiapp/protected/models/TbUser.php Tb_User模型类

<?php

/**
 * This is the model class for table "tb_user".
 * 这个模型类表“tb_user”。
 * 
 * The followings are the available columns in table 'tb_user':
 * 以下是可用的列表'tb_user':
 * @property integer $id
 * @property string $username
 * @property string $password
 * @property integer $time
 */
class TbUser extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return TbUser the static model class
	 * 返回指定的AR类的静态模型。
     * @参数字符串$ className的活动记录类的名称。
     * @返回TbUser静态模型类
	 */
	public static function model($className=__CLASS__)
	{
		//echo "className:{$className}<BR>";
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 * 返回数据库表名
	 */
	public function tableName()
	{
		return 'tb_user';
	}

	/**
	 * @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('username, password, time', 'required'), //必须填
			array('time', 'numerical', 'integerOnly'=>true),  //time和numerical必须是int型?
			array('username, password', 'length', 'max'=>100), //用户和密码的最大长度不能大于100
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			// 下面的规则用于搜索()。
			// 请删除那些属性不应该被搜索。
			array('id, username, password, time', '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(
			'id' => 'ID',
			'username' => 'Username',
			'password' => 'Password',
			'time' => 'Time',
		);
	}

	/**
	 * 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.
	 * 检索的列表模式,根据当前的搜索/过滤条件。
     * @返回CActiveDataProvider的数据供应商,可以返回模型基础上的搜索/过滤条件。
	 */
	public function search()
	{
		
		echo "<h2>search</h2>";
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.
		// 警告:请修改下面的代码删除属性
		// 不应该被搜查。
		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('password',$this->password,true);
		$criteria->compare('time',$this->time);

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

  

posted @ 2013-06-22 17:38  简单--生活  阅读(247)  评论(0)    收藏  举报
简单--生活(CSDN)