getDbConnection()->beginTransaction(); try{ $setting=$this->getDbConnection()->createCommand("select * from assist_setting limit 1")->queryRow(); if($setting){ $insertSql="insert into assist_setting(`accept_school_open`,`cutting_task`,`open_cutting_upper_limit`,`cutting_task_upper_limit_num`,`scan_task`,`open_scan_upper_limit`,`scan_task_upper_limit_num`) values "; $insertSql.="('".$setting['accept_school_open']."','".$data['cutting_task']."','".$data['open_cutting_upper_limit']."','".$data['cutting_task_upper_limit_num']."','".$data['scan_task']."','".$data['open_scan_upper_limit']."','".$data['scan_task_upper_limit_num']."')"; }else{ $insertSql="insert into assist_setting(`accept_school_open`,`cutting_task`,`open_cutting_upper_limit`,`cutting_task_upper_limit_num`,`scan_task`,`open_scan_upper_limit`,`scan_task_upper_limit_num`) values "; $insertSql.="('0','".$data['cutting_task']."','".$data['open_cutting_upper_limit']."','".$data['cutting_task_upper_limit_num']."','".$data['scan_task']."','".$data['open_scan_upper_limit']."','".$data['scan_task_upper_limit_num']."')"; } $this->getDbConnection()->createCommand("delete from assist_setting ")->execute(); $this->getDbConnection()->createCommand($insertSql)->execute(); $trans->commit(); return true; }catch (Exception $e){ $trans->rollback(); } return false; } //读取后台设置 public function getAssistSetting(){ $setting=$this->getDbConnection()->createCommand("select accept_school_open,cutting_task,open_cutting_upper_limit,cutting_task_upper_limit_num,scan_task,open_scan_upper_limit,scan_task_upper_limit_num from assist_setting limit 1")->queryRow(); return $setting; } //修改后台学校开关 public function updateAssistSchoolSetting($data){ if(!$data) return false; $trans = $this->getDbConnection()->beginTransaction(); try{ $setting=$this->getDbConnection()->createCommand("select * from assist_setting limit 1")->queryRow(); if($setting){ $insertSql="insert into assist_setting(`accept_school_open`,`cutting_task`,`open_cutting_upper_limit`,`cutting_task_upper_limit_num`,`scan_task`,`open_scan_upper_limit`,`scan_task_upper_limit_num`) values "; $insertSql.="('".$data['accept_school_open']."','".$setting['cutting_task']."','".$setting['open_cutting_upper_limit']."','".$setting['cutting_task_upper_limit_num']."','".$setting['scan_task']."','".$setting['open_scan_upper_limit']."','".$setting['scan_task_upper_limit_num']."')"; }else{ $insertSql="insert into assist_setting(`accept_school_open`,`cutting_task`,`open_cutting_upper_limit`,`cutting_task_upper_limit_num`,`scan_task`,`open_scan_upper_limit`,`scan_task_upper_limit_num`) values "; $insertSql.="('".$data['accept_school_open']."','1','0','0','1','0','0')"; } $this->getDbConnection()->createCommand("delete from assist_setting ")->execute(); $this->getDbConnection()->createCommand($insertSql)->execute(); $trans->commit(); return true; }catch (Exception $e){ $trans->rollback(); } return false; } }