123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- /**
- * @author: CeeFee
- * @description: 考试
- */
- class Cylet extends Model
- {
- function __construct(){
- parent::__construct();
- }
- public function getList($grade,$class,$semester_id,$page,$pagelimit,$is_display=0,$arts_science=0,$cylet_type=0){
- $result=array();
- $where =" is_display = ".$is_display." ";
- if($class){
- $where.=" And find_in_set(".$class.",class_ids) ";
- }
- if($grade){
- $where.=" And grade={$grade} ";
- }
- if($semester_id){
- $where.=" And semester_id={$semester_id} ";
- }
- if($arts_science){
- $where.=" And arts_science={$arts_science} ";
- }
- if($cylet_type){
- $where.=" And cylet_type={$cylet_type} ";
- }
- $dataCount = $this->sConn->createCommand()
- ->from('cylet')
- ->where($where)
- ->query()
- ->count();
- $result['totalCount']=$dataCount;
- $result['pageTotal']=ceil($dataCount/$pagelimit);
- $offset=($page-1)*$pagelimit;
- $data=$this->sConn->createCommand()
- ->from('cylet')
- ->where($where)
- ->offset($offset)
- ->limit($pagelimit)
- ->order('create_time desc')
- ->query()
- ->readAll();
- $result['data']=$data;
- return $result;
- }
- /*修改状态*/
- public function updateByCondition($data,$condition){
- $result=0;
- if(!$data || !$condition || !is_array($data) || !is_array($condition)){
- return false;
- }
- $set=array();
- $where=array();
- foreach($data as $key=>$val){
- $set[]="`".$key."` = '".$val."'";
- }
- foreach ($condition as $key=>$val){
- $where[]='`'.$key.'` = '.$val;
- }
- if($where && $set){
- $Sql=" Update `cylet` ";
- $Sql.=" set ".implode(', ',$set);
- $Sql.=" where ".implode(' And ',$where);
- $result=$this->sConn->createCommand($Sql)->execute();
- }
- return $result;
- }
- public function findById($cid){
- $data=$this->sConn->createCommand()
- ->from('cylet')
- ->where("cylet_id=:cid")
- ->bindParam(":cid",$cid)
- ->query()
- ->read();
- return $data;
- }
- public function InsertByData($data){
- if($this->sConn->createCommand()->insert('cylet',$data)){
- return $this->sConn->getLastInsertID();
- }else{
- return 0;
- }
- }
- public function getByTime($create_time,$grade,$arts_science){
- $data=$this->sConn->createCommand()
- ->from('cylet')
- ->where("create_time=:time and grade=:grade and arts_science=:arts_science")
- ->bindParam(":time",$create_time)
- ->bindParam(":grade",$grade)
- ->bindParam(":arts_science",$arts_science)
- ->query()
- ->read();
- return $data;
- }
- }
|