Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.97 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * This is the model class for table "prod_category".
  5.  *
  6.  * The followings are the available columns in table 'prod_category':
  7.  * @property string $id_cat
  8.  * @property string $cat_par
  9.  * @property string $cat_prior
  10.  * @property string $cat_name
  11.  * @property string $cat_alias
  12.  * @property string $cat_end
  13.  * @property string $cat_visible
  14.  * @property string $cat_img
  15.  * @property string $cat_img_thumb
  16.  * @property string $cat_deleted
  17.  * @property integer $cat_create_date
  18.  * @property integer $cat_modify_date
  19.  * @property string $cat_title
  20.  * @property string $cat_description
  21.  * @property string $cat_keywords
  22.  * @property integer $id_atree
  23.  * @property string $cat_img_pda
  24.  * @property integer $id_photo_type
  25.  * @property string $rdfa_name
  26.  * @property string $link_to_brand
  27.  * @property string $cat_name_ru
  28.  * @property string $cat_meta_description
  29.  */
  30. class ProdCategory extends CActiveRecord
  31. {
  32.     public $prod_name;
  33.     public $id_prod;
  34.     public $prod_alias;
  35.     public $prod_img;
  36.     public $prod_img_thumb;
  37.    
  38.     public function getProdlink(){
  39.         return $this->prod_alias.'_'.$this->id_prod;
  40.     }
  41.  
  42.     public function tableName()
  43.     {
  44.         return 'prod_category';
  45.     }
  46.  
  47.     /**
  48.      * @return array validation rules for model attributes.
  49.      */
  50.     public function rules()
  51.     {
  52.         // NOTE: you should only define rules for those attributes that
  53.         // will receive user inputs.
  54.         return array(
  55.             array('cat_alias, cat_create_date, cat_modify_date, cat_title, cat_description, cat_keywords, cat_img_pda, rdfa_name, link_to_brand, cat_name_ru, cat_meta_description', 'required'),
  56.             array('cat_create_date, cat_modify_date, id_atree, id_photo_type', 'numerical', 'integerOnly'=>true),
  57.             array('cat_par, cat_prior', 'length', 'max'=>10),
  58.             array('cat_name, cat_img, cat_img_thumb, cat_title, cat_img_pda, rdfa_name, link_to_brand', 'length', 'max'=>255),
  59.             array('cat_alias', 'length', 'max'=>100),
  60.             array('cat_end, cat_visible, cat_deleted', 'length', 'max'=>3),
  61.             array('cat_name_ru', 'length', 'max'=>455),
  62.             // The following rule is used by search().
  63.             // @todo Please remove those attributes that should not be searched.
  64.             array('id_cat, cat_par, cat_prior, cat_name, cat_alias, cat_end, cat_visible, cat_img, cat_img_thumb, cat_deleted, cat_create_date, cat_modify_date, cat_title, cat_description, cat_keywords, id_atree, cat_img_pda, id_photo_type, rdfa_name, link_to_brand, cat_name_ru, cat_meta_description', 'safe', 'on'=>'search'),
  65.         );
  66.     }
  67.  
  68.     /**
  69.      * @return array relational rules.
  70.      */
  71.     public function relations()
  72.     {
  73.         return array(
  74.         'Production' => array(self::MANY_MANY, 'Production', 'prod_join_cat(id_prod, id_prod)'),
  75.         );
  76.     }
  77.  
  78.     /**
  79.      * @return array customized attribute labels (name=>label)
  80.      */
  81.     public function attributeLabels()
  82.     {
  83.         return array(
  84.             'id_cat' => 'Id Cat',
  85.             'cat_par' => 'Cat Par',
  86.             'cat_prior' => 'Cat Prior',
  87.             'cat_name' => 'Cat Name',
  88.             'cat_alias' => 'Cat Alias',
  89.             'cat_end' => 'Cat End',
  90.             'cat_visible' => 'Cat Visible',
  91.             'cat_img' => 'Cat Img',
  92.             'cat_img_thumb' => 'Cat Img Thumb',
  93.             'cat_deleted' => 'Cat Deleted',
  94.             'cat_create_date' => 'Cat Create Date',
  95.             'cat_modify_date' => 'Cat Modify Date',
  96.             'cat_title' => 'Cat Title',
  97.             'cat_description' => 'Cat Description',
  98.             'cat_keywords' => 'Cat Keywords',
  99.             'id_atree' => 'Id Atree',
  100.             'cat_img_pda' => 'Cat Img Pda',
  101.             'id_photo_type' => 'Id Photo Type',
  102.             'rdfa_name' => 'Rdfa Name',
  103.             'link_to_brand' => 'Link To Brand',
  104.             'cat_name_ru' => 'Cat Name Ru',
  105.             'cat_meta_description' => 'Cat Meta Description',
  106.         );
  107.     }
  108.  
  109.     /**
  110.      * Retrieves a list of models based on the current search/filter conditions.
  111.      *
  112.      * Typical usecase:
  113.      * - Initialize the model fields with values from filter form.
  114.      * - Execute this method to get CActiveDataProvider instance which will filter
  115.      * models according to data in model fields.
  116.      * - Pass data provider to CGridView, CListView or any similar widget.
  117.      *
  118.      * @return CActiveDataProvider the data provider that can return the models
  119.      * based on the search/filter conditions.
  120.      */
  121.     public function search()
  122.     {
  123.         // @todo Please modify the following code to remove attributes that should not be searched.
  124.  
  125.         $criteria=new CDbCriteria;
  126.  
  127.         $criteria->compare('id_cat',$this->id_cat,true);
  128.         $criteria->compare('cat_par',$this->cat_par,true);
  129.         $criteria->compare('cat_prior',$this->cat_prior,true);
  130.         $criteria->compare('cat_name',$this->cat_name,true);
  131.         $criteria->compare('cat_alias',$this->cat_alias,true);
  132.         $criteria->compare('cat_end',$this->cat_end,true);
  133.         $criteria->compare('cat_visible',$this->cat_visible,true);
  134.         $criteria->compare('cat_img',$this->cat_img,true);
  135.         $criteria->compare('cat_img_thumb',$this->cat_img_thumb,true);
  136.         $criteria->compare('cat_deleted',$this->cat_deleted,true);
  137.         $criteria->compare('cat_create_date',$this->cat_create_date);
  138.         $criteria->compare('cat_modify_date',$this->cat_modify_date);
  139.         $criteria->compare('cat_title',$this->cat_title,true);
  140.         $criteria->compare('cat_description',$this->cat_description,true);
  141.         $criteria->compare('cat_keywords',$this->cat_keywords,true);
  142.         $criteria->compare('id_atree',$this->id_atree);
  143.         $criteria->compare('cat_img_pda',$this->cat_img_pda,true);
  144.         $criteria->compare('id_photo_type',$this->id_photo_type);
  145.         $criteria->compare('rdfa_name',$this->rdfa_name,true);
  146.         $criteria->compare('link_to_brand',$this->link_to_brand,true);
  147.         $criteria->compare('cat_name_ru',$this->cat_name_ru,true);
  148.         $criteria->compare('cat_meta_description',$this->cat_meta_description,true);
  149.  
  150.         return new CActiveDataProvider($this, array(
  151.             'criteria'=>$criteria,
  152.         ));
  153.     }
  154.  
  155.  
  156.     /**
  157.      * Returns the static model of the specified AR class.
  158.      * Please note that you should have this exact method in all your CActiveRecord descendants!
  159.      * @param string $className active record class name.
  160.      * @return ProdCategory the static model class
  161.      */
  162.     public static function model($className=__CLASS__)
  163.     {
  164.         return parent::model($className);
  165.     }
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement