<?php
class GroupTopicPost extends CActiveRecord {
/**
* @return string the associated database table name
*/
public function tableName() {
return '{{group_topic_posts}}';
}
/**
* @return array validation rules for model attributes.
*/
public function rules() {
return array(
array('author_id, topic_id, text', 'required'),
array('author_id, topic_id', 'length', 'max' => 10),
array('text', 'filter', 'filter' => 'trim'),
// The following rule is used by search().
array('id, created_at, author_id, topic_id, text, update_datetime', 'safe', 'on' => 'search'),
);
}
/**
* @return array relational rules.
*/
public function relations() {
return array(
'author' => array(self::BELONGS_TO, 'User', 'author_id'),
'topic' => array(self::BELONGS_TO, 'GroupTopic', 'topic_id'),
);
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return TopicPost the static model class
*/
public static function model($className=__CLASS__) {
return parent::model($className);
}
}