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; } }