getCommandBuilder()->createSqlCommand($sql)->queryColumn(); if($info){ $rs=$this->getCommandBuilder()->createSqlCommand("update exam_push_topics_setting set topic_ids='".$topics."',datetime='".time()."' where exam_id='".$examId."'")->execute(); }else{ $rs=$this->getCommandBuilder()->createSqlCommand("insert into exam_push_topics_setting(`exam_group_id`,`exam_id`,`topic_ids`,`datetime`) values('".$examGroupId."','".$examId."','".$topics."','".time()."')")->execute(); } return $rs; } /** * 批量保存试题推送 */ public function updateSettingBatch($examIds,$examGroupId,$topics){ if(!$examIds || !is_array($examIds)) return false; if($topics){ $topics=jsonEncode($topics); $sql="replace into exam_push_topics_setting(`exam_group_id`,`exam_id`,`topic_ids`,`datetime`) values "; $value=array(); foreach ($examIds as $id){ $value[]="('".$examGroupId."','".$id."','".$topics."','".time()."')"; } $rs=$this->getCommandBuilder()->createSqlCommand($sql.implode(',',$value))->execute(); }else{ $sql="delete from exam_push_topics_setting where exam_id in(".implode(',',$examIds).")"; $rs=$this->getCommandBuilder()->createSqlCommand($sql)->execute(); } return $rs; } /** * 读取试题推送设置 */ public function getTopicSetting($examGroupId){ $sql="select exam_id,topic_ids from exam_push_topics_setting where exam_group_id='".$examGroupId."'"; $info = $this->getCommandBuilder()->createSqlCommand($sql)->queryAll(); return $info; } }