Its Page model let me copy my model here, i hope i am not troubling you. sorry !
<?php
class Page extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Page 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 'page';
}
/**
* @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('category_id, topic_id, title, url', 'required'),
array('category_id, topic_id, hits, status', 'numerical', 'integerOnly'=>true),
array('title, seoDesc, image, tags', 'length', 'max'=>245),
array('url', 'length', 'max'=>100),
array('seoTitle', 'length', 'max'=>120),
array('summary, detail, postDate', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, category_id, topic_id, title, url, seoTitle, seoDesc, image, summary, detail, tags, hits, postDate, status', '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(
'category' => array(self::BELONGS_TO, 'Category', 'category_id'),
'topic' => array(self::BELONGS_TO, 'Topic', 'topic_id'),
'pagefacts' => array(self::HAS_MANY, 'Pagefact', 'page_id'),
'pageimages' => array(self::HAS_MANY, 'Pageimages', 'page_id'),
'pagevideoses' => array(self::HAS_MANY, 'Pagevideos', 'page_id'),
'tags0' => array(self::HAS_MANY, 'Tag', 'page_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'category_id' => 'Category',
'topic_id' => 'Topic',
'title' => 'Title',
'url' => 'Url',
'seoTitle' => 'Seo Title',
'seoDesc' => 'Seo Desc',
'image' => 'Image',
'summary' => 'Summary',
'detail' => 'Detail',
'tags' => 'Tags',
'hits' => 'Hits',
'postDate' => 'Post Date',
'status' => 'Status',
);
}
/**
* 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',$this->id);
$criteria->compare('category_id',$this->category_id);
$criteria->compare('topic_id',$this->topic_id);
$criteria->compare('title',$this->title,true);
$criteria->compare('url',$this->url,true);
$criteria->compare('seoTitle',$this->seoTitle,true);
$criteria->compare('seoDesc',$this->seoDesc,true);
$criteria->compare('image',$this->image,true);
$criteria->compare('summary',$this->summary,true);
$criteria->compare('detail',$this->detail,true);
$criteria->compare('tags',$this->tags,true);
$criteria->compare('hits',$this->hits);
$criteria->compare('postDate',$this->postDate,true);
$criteria->compare('status',$this->status);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
}