SSubjectStyleVersion.php 861 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. class SSubjectStyleVersion extends MyActiveRecord
  3. {
  4. public static function model($className = __CLASS__)
  5. {
  6. return parent::model($className);
  7. }
  8. public function tableName()
  9. {
  10. return 'subject_style_version';
  11. }
  12. /**
  13. * 获取学科样式类型
  14. * @param $subjectId
  15. * @return int
  16. */
  17. public function getStyleType($subjectId)
  18. {
  19. $model = self::model()->find('subject_id=:subject_id',array(':subject_id'=>$subjectId));
  20. if($model){
  21. return $model->style_type;
  22. }else{
  23. $time = time();
  24. $model = new self();
  25. $model->subject_id = $subjectId;
  26. $model->style_type = 0;
  27. $model->update_time = $time;
  28. $model->create_time = $time;
  29. $model->save();
  30. return 0;
  31. }
  32. }
  33. }