Cylet.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * @author: CeeFee
  4. * @description: 考试
  5. */
  6. class Cylet extends Model
  7. {
  8. function __construct(){
  9. parent::__construct();
  10. }
  11. public function getList($grade,$class,$semester_id,$page,$pagelimit,$is_display=0,$arts_science=0,$cylet_type=0){
  12. $result=array();
  13. $where =" is_display = ".$is_display." ";
  14. if($class){
  15. $where.=" And find_in_set(".$class.",class_ids) ";
  16. }
  17. if($grade){
  18. $where.=" And grade={$grade} ";
  19. }
  20. if($semester_id){
  21. $where.=" And semester_id={$semester_id} ";
  22. }
  23. if($arts_science){
  24. $where.=" And arts_science={$arts_science} ";
  25. }
  26. if($cylet_type){
  27. $where.=" And cylet_type={$cylet_type} ";
  28. }
  29. $dataCount = $this->sConn->createCommand()
  30. ->from('cylet')
  31. ->where($where)
  32. ->query()
  33. ->count();
  34. $result['totalCount']=$dataCount;
  35. $result['pageTotal']=ceil($dataCount/$pagelimit);
  36. $offset=($page-1)*$pagelimit;
  37. $data=$this->sConn->createCommand()
  38. ->from('cylet')
  39. ->where($where)
  40. ->offset($offset)
  41. ->limit($pagelimit)
  42. ->order('create_time desc')
  43. ->query()
  44. ->readAll();
  45. $result['data']=$data;
  46. return $result;
  47. }
  48. /*修改状态*/
  49. public function updateByCondition($data,$condition){
  50. $result=0;
  51. if(!$data || !$condition || !is_array($data) || !is_array($condition)){
  52. return false;
  53. }
  54. $set=array();
  55. $where=array();
  56. foreach($data as $key=>$val){
  57. $set[]="`".$key."` = '".$val."'";
  58. }
  59. foreach ($condition as $key=>$val){
  60. $where[]='`'.$key.'` = '.$val;
  61. }
  62. if($where && $set){
  63. $Sql=" Update `cylet` ";
  64. $Sql.=" set ".implode(', ',$set);
  65. $Sql.=" where ".implode(' And ',$where);
  66. $result=$this->sConn->createCommand($Sql)->execute();
  67. }
  68. return $result;
  69. }
  70. public function findById($cid){
  71. $data=$this->sConn->createCommand()
  72. ->from('cylet')
  73. ->where("cylet_id=:cid")
  74. ->bindParam(":cid",$cid)
  75. ->query()
  76. ->read();
  77. return $data;
  78. }
  79. public function InsertByData($data){
  80. if($this->sConn->createCommand()->insert('cylet',$data)){
  81. return $this->sConn->getLastInsertID();
  82. }else{
  83. return 0;
  84. }
  85. }
  86. public function getByTime($create_time,$grade,$arts_science){
  87. $data=$this->sConn->createCommand()
  88. ->from('cylet')
  89. ->where("create_time=:time and grade=:grade and arts_science=:arts_science")
  90. ->bindParam(":time",$create_time)
  91. ->bindParam(":grade",$grade)
  92. ->bindParam(":arts_science",$arts_science)
  93. ->query()
  94. ->read();
  95. return $data;
  96. }
  97. }