CMSOrderStudent.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * Created by 上海互教教育科技有限公司.
  4. * User: 刘红伟
  5. * Date: 2016/7/19
  6. * Email: 454303753@qq.com
  7. * File:CMSOrderStudent.php
  8. */
  9. class CMSOrderStudent extends CActiveRecord
  10. {
  11. public function getDbConnection()
  12. {
  13. return Yii::app()->db251;
  14. }
  15. public static function model($className = __CLASS__)
  16. {
  17. return parent::model($className);
  18. }
  19. public function tableName()
  20. {
  21. return "order_student";
  22. }
  23. public function getOrderIDByClassId($class_id='',$student_id='')
  24. {
  25. $criteria = new CDbCriteria();
  26. if($class_id!="-1")
  27. {
  28. $criteria->addCondition('clazz_id=:clazz_id');
  29. $criteria->params[':clazz_id'] = $class_id;
  30. }
  31. if($student_id!="-1")
  32. {
  33. $criteria->addCondition('student_id=:student_id');
  34. $criteria->params[':student_id'] = $student_id;
  35. }
  36. $data = $this->findAll($criteria);
  37. if($data)
  38. {
  39. return $data;
  40. }
  41. return false;
  42. }
  43. public function getOrderIDInClassId($class_ids=array(),$student_id='')
  44. {
  45. $criteria = new CDbCriteria();
  46. if($class_ids)
  47. {
  48. $criteria->addInCondition('clazz_id ',$class_ids);
  49. // $criteria->params[':clazz_id'] = implode(",", $class_ids);
  50. }
  51. if($student_id!=-1)
  52. {
  53. $criteria->addCondition('student_id=:student_id');
  54. $criteria->params[':student_id'] = $student_id;
  55. }
  56. $data = $this->findAll($criteria);
  57. if($data)
  58. {
  59. return $data;
  60. }
  61. return false;
  62. }
  63. public function getPageList($school_id){
  64. $data = array();
  65. $criteria = new CDbCriteria();
  66. $criteria->addCondition('order_id=:order_id');
  67. $criteria->params[':school_id'] = $school_id;
  68. $total = $this->count($criteria);
  69. $pager = new CPagination($total);
  70. $criteria->order = 'id desc';
  71. $pager->pageSize = 12;
  72. $pager->applyLimit($criteria);
  73. $data['result'] = $this->findAll($criteria);
  74. $data['page'] = $pager;
  75. $data['page_total'] = $total;
  76. return $data;
  77. }
  78. }