BusinessZl_report_setting.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * 学校模型类
  4. * @author jiangfei
  5. * @date 2015-10-29 13:30:00
  6. * @company 上海风车教育有限公司.
  7. */
  8. class BusinessZl_report_setting extends BusinessActiveRecord{
  9. public static function model($className = __CLASS__){
  10. return parent::model($className);
  11. }
  12. public function tableName(){
  13. return "zl_report_setting";
  14. }
  15. //查询学校设置
  16. public function getReportSetting($schoolId){
  17. $data = array();
  18. $sql = "select * from zl_report_setting where school_id = '{$schoolId}'";
  19. $result=$this->getDbConnection()->createCommand($sql)->queryRow();
  20. if($result){
  21. $data = $result;
  22. }
  23. return $data;
  24. }
  25. //保存设置
  26. public function saveReportSetting($schoolId,$insertData=array()){
  27. $result = false;
  28. $time = time();
  29. if($schoolId && $insertData){
  30. $sql = "select * from zl_report_setting where school_id = '{$schoolId}'";
  31. $data = $this->getDbConnection()->createCommand($sql)->queryRow();
  32. if($data){//有更新
  33. $sql = "update zl_report_setting set class_average=".$insertData["class_average"].",grade_average=".$insertData["grade_average"].",class_rank=".$insertData["class_rank"].",grade_rank=".$insertData["grade_rank"].",level_replace_score=".$insertData["level_replace_score"].",score_level_setting='".$insertData["score_level_setting"]."',update_time=".$time." where school_id = '{$schoolId}'";
  34. $result = $this->getDbConnection()->createCommand($sql)->execute();
  35. }else{//没有插入
  36. $sql = "insert zl_report_setting (`school_id`,`class_average`,`grade_average`,`class_rank`,`grade_rank`,`level_replace_score`,`score_level_setting`,`create_time`)
  37. values (".$schoolId.",".$insertData["class_average"].",".$insertData["grade_average"].",".$insertData["class_rank"].",".$insertData["grade_rank"].",".$insertData["level_replace_score"].",'".$insertData["score_level_setting"]."',".$time.")";
  38. $result = $this->getDbConnection()->createCommand($sql)->execute();
  39. }
  40. }
  41. return $result;
  42. }
  43. }