1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /**
- * 学校模型类
- * @author jiangfei
- * @date 2015-10-29 13:30:00
- * @company 上海风车教育有限公司.
- */
- class BusinessZl_report_setting extends BusinessActiveRecord{
- public static function model($className = __CLASS__){
- return parent::model($className);
- }
- public function tableName(){
- return "zl_report_setting";
- }
- //查询学校设置
- public function getReportSetting($schoolId){
- $data = array();
- $sql = "select * from zl_report_setting where school_id = '{$schoolId}'";
- $result=$this->getDbConnection()->createCommand($sql)->queryRow();
- if($result){
- $data = $result;
- }
- return $data;
- }
- //保存设置
- public function saveReportSetting($schoolId,$insertData=array()){
- $result = false;
- $time = time();
- if($schoolId && $insertData){
- $sql = "select * from zl_report_setting where school_id = '{$schoolId}'";
- $data = $this->getDbConnection()->createCommand($sql)->queryRow();
- if($data){//有更新
- $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}'";
- $result = $this->getDbConnection()->createCommand($sql)->execute();
- }else{//没有插入
- $sql = "insert zl_report_setting (`school_id`,`class_average`,`grade_average`,`class_rank`,`grade_rank`,`level_replace_score`,`score_level_setting`,`create_time`)
- values (".$schoolId.",".$insertData["class_average"].",".$insertData["grade_average"].",".$insertData["class_rank"].",".$insertData["grade_rank"].",".$insertData["level_replace_score"].",'".$insertData["score_level_setting"]."',".$time.")";
- $result = $this->getDbConnection()->createCommand($sql)->execute();
- }
- }
- return $result;
- }
- }
|