123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- class SSubjectStyleVersion extends MyActiveRecord
- {
- public static function model($className = __CLASS__)
- {
- return parent::model($className);
- }
- public function tableName()
- {
- return 'subject_style_version';
- }
- /**
- * 获取学科样式类型
- * @param $subjectId
- * @return int
- */
- public function getStyleType($subjectId)
- {
- $model = self::model()->find('subject_id=:subject_id',array(':subject_id'=>$subjectId));
- if($model){
- return $model->style_type;
- }else{
- $time = time();
- $model = new self();
- $model->subject_id = $subjectId;
- $model->style_type = 0;
- $model->update_time = $time;
- $model->create_time = $time;
- $model->save();
- return 0;
- }
- }
- }
|