Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * This is the model class for table "tbl_user".
  5. *
  6. * The followings are the available columns in table 'tbl_user':
  7. * @property integer $id
  8. * @property string $username
  9. * @property string $password
  10. * @property string $email
  11. */
  12. class TblUser extends CActiveRecord
  13. {
  14. /**
  15. * @return string the associated database table name
  16. */
  17. public function tableName()
  18. {
  19. return 'tbl_user';
  20. }
  21.  
  22. /**
  23. * @return array validation rules for model attributes.
  24. */
  25. public function rules()
  26. {
  27. // NOTE: you should only define rules for those attributes that
  28. // will receive user inputs.
  29. return array(
  30. array('id, username, password, email', 'required'),
  31. array('id', 'numerical', 'integerOnly'=>true),
  32. array('username, email', 'length', 'max'=>50),
  33. array('password', 'length', 'max'=>15),
  34. // The following rule is used by search().
  35. // @todo Please remove those attributes that should not be searched.
  36. array('id, username, password, email', 'safe', 'on'=>'search'),
  37. );
  38. }
  39.  
  40. /**
  41. * @return array relational rules.
  42. */
  43. public function relations()
  44. {
  45. // NOTE: you may need to adjust the relation name and the related
  46. // class name for the relations automatically generated below.
  47. return array(
  48. );
  49. }
  50.  
  51. /**
  52. * @return array customized attribute labels (name=>label)
  53. */
  54. public function attributeLabels()
  55. {
  56. return array(
  57. 'id' => 'ID',
  58. 'username' => 'Username',
  59. 'password' => 'Password',
  60. 'email' => 'Email',
  61. );
  62. }
  63.  
  64. /**
  65. * Retrieves a list of models based on the current search/filter conditions.
  66. *
  67. * Typical usecase:
  68. * - Initialize the model fields with values from filter form.
  69. * - Execute this method to get CActiveDataProvider instance which will filter
  70. * models according to data in model fields.
  71. * - Pass data provider to CGridView, CListView or any similar widget.
  72. *
  73. * @return CActiveDataProvider the data provider that can return the models
  74. * based on the search/filter conditions.
  75. */
  76. public function search()
  77. {
  78. // @todo Please modify the following code to remove attributes that should not be searched.
  79.  
  80. $criteria=new CDbCriteria;
  81.  
  82. $criteria->compare('id',$this->id);
  83. $criteria->compare('username',$this->username,true);
  84. $criteria->compare('password',$this->password,true);
  85. $criteria->compare('email',$this->email,true);
  86.  
  87. return new CActiveDataProvider($this, array(
  88. 'criteria'=>$criteria,
  89. ));
  90. }
  91.  
  92. /**
  93. * Returns the static model of the specified AR class.
  94. * Please note that you should have this exact method in all your CActiveRecord descendants!
  95. * @param string $className active record class name.
  96. * @return TblUser the static model class
  97. */
  98. public static function model($className=__CLASS__)
  99. {
  100. return parent::model($className);
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement