Advertisement
amjithps

Untitled

Sep 16th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.03 KB | None | 0 0
  1. <?php
  2.  
  3. /** * This is the model class for table "
  4. custom_attachments". * * The followings are the available columns in table '
  5. custom_attachments':
  6. * @property
  7. integer $id
  8. * @property
  9. integer $user_id
  10. * @property
  11. string $title
  12. * @property
  13. string $description
  14. * @property
  15. string $attachment
  16. * @property
  17. string $created
  18. * @property
  19. string $modified
  20. */ class
  21. CustomAttachmentsextends
  22. CActiveRecord
  23. { /** * @return string the associated database table name */ public
  24. function tableName() { return '
  25. custom_attachments'; } /** * @return array validation rules for model attributes. */
  26. public function rules() { // NOTE: you should only define rules for
  27. those attributes that // will receive user inputs. return array(
  28. array('user_id, title, description, attachment, created, modified', 'required'),
  29. array('user_id', 'numerical', 'integerOnly'=>true),
  30. array('title, attachment', 'length', 'max'=>255),
  31. // The following rule is used by search(). // @todo Please remove those
  32. attributes that should not be searched. array('
  33. id, user_id, title, description, attachment, created, modified', 'safe', 'on'=>'search'), ); } /** * @return array relational rules.
  34. */ public function relations() { // NOTE: you may need to adjust the
  35. relation name and the related // class name for the relations
  36. automatically generated below. return array(
  37. ); } /** * @return array customized attribute labels (name=>label) */
  38. public function attributeLabels() { return array(
  39. 'id' => 'ID',
  40. 'user_id' => 'User',
  41. 'title' => 'Title',
  42. 'description' => 'Description',
  43. 'attachment' => 'Attachment',
  44. 'created' => 'Created',
  45. 'modified' => 'Modified',
  46. ); } /** * Retrieves a list of models based on the current search/filter
  47. conditions. * * Typical usecase: * - Initialize the model fields with
  48. values from filter form. * - Execute this method to get
  49. CActiveDataProvider instance which will filter * models according to
  50. data in model fields. * - Pass data provider to CGridView, CListView or
  51. any similar widget. * * @return CActiveDataProvider the data provider
  52. that can return the models * based on the search/filter conditions. */
  53. public function search() { // @todo Please modify the following code to
  54. remove attributes that should not be searched. $criteria=new
  55. CDbCriteria;
  56.  
  57.         $criteria->compare('id',$this->id);
  58.         $criteria->compare('user_id',$this->user_id);
  59.         $criteria->compare('title',$this->title,true);
  60.         $criteria->compare('description',$this->description,true);
  61.         $criteria->compare('attachment',$this->attachment,true);
  62.         $criteria->compare('created',$this->created,true);
  63.         $criteria->compare('modified',$this->modified,true);
  64.  
  65. return new CActiveDataProvider($this, array( 'criteria'=>$criteria, ));
  66. }
  67.  
  68. /** * Returns the static model of the specified AR class. * Please note
  69. that you should have this exact method in all your CActiveRecord
  70. descendants! * @param string $className active record class name. *
  71. @return
  72. CustomAttachmentsthe static model class */ public static function
  73. model($className=__CLASS__) { return parent::model($className); } }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement