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