AssistUser.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * 驻场教练模型类
  4. * @author jiangfei
  5. * @date 2015-07-20 10:30:00
  6. * @company 上海风车教育有限公司.
  7. */
  8. class AssistUser extends BusinessActiveRecord{
  9. public static function model($className = __CLASS__){
  10. return parent::model($className);
  11. }
  12. public function tableName(){
  13. return "assist_user";
  14. }
  15. public function primaryKey(){
  16. return array('user_id');
  17. }
  18. public function getLesseeList($page=1,$pageLimit=15)
  19. {
  20. $offset=($page-1)*$pageLimit;
  21. $pages=array();
  22. $totalQuery=$this->getDbConnection()->createCommand("select count(*) as count from assist_user where role=1")->queryRow();
  23. $pages['total']=$totalQuery['count'];
  24. $pages['totalPage']=ceil($totalQuery['count']/$pageLimit);
  25. $pages['page']=$page;
  26. $data = $this->getDbConnection()->createCommand("
  27. select user_id,user_name,real_name,sex,role,update_time,status,user_origin,cutting_limit,scan_limit
  28. from assist_user
  29. where role=1
  30. order by user_id desc
  31. limit {$offset},{$pageLimit}
  32. ")->queryAll();
  33. $return['pages']=$pages;
  34. $return['dataList']=$data;
  35. return $return;
  36. }
  37. public function getAllUser(){
  38. $data = $this->getDbConnection()->createCommand("
  39. select user_id,user_name,real_name,sex,role,update_time,status
  40. from assist_user
  41. where role=1 and status=1
  42. order by user_id desc
  43. ")->queryAll();
  44. return $data;
  45. }
  46. public function getAllUserByLimit($condition){
  47. $sql="select user_id,user_name,real_name,sex,role,update_time,status
  48. from assist_user ";
  49. $where=array();
  50. $where[]="role=1 ";
  51. $where[]="status=1 ";
  52. if($condition){
  53. $where[]=$condition;
  54. }
  55. $sql.=" where ".implode(' and ',$where);
  56. $data = $this->getDbConnection()->createCommand($sql)->queryAll();
  57. return $data;
  58. }
  59. }