12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- /**
- * 驻场教练模型类
- * @author jiangfei
- * @date 2015-07-20 10:30:00
- * @company 上海风车教育有限公司.
- */
- class AssistUser extends BusinessActiveRecord{
-
- public static function model($className = __CLASS__){
- return parent::model($className);
- }
- public function tableName(){
- return "assist_user";
- }
- public function primaryKey(){
- return array('user_id');
- }
- public function getLesseeList($page=1,$pageLimit=15)
- {
- $offset=($page-1)*$pageLimit;
- $pages=array();
- $totalQuery=$this->getDbConnection()->createCommand("select count(*) as count from assist_user where role=1")->queryRow();
- $pages['total']=$totalQuery['count'];
- $pages['totalPage']=ceil($totalQuery['count']/$pageLimit);
- $pages['page']=$page;
- $data = $this->getDbConnection()->createCommand("
- select user_id,user_name,real_name,sex,role,update_time,status,user_origin,cutting_limit,scan_limit
- from assist_user
- where role=1
- order by user_id desc
- limit {$offset},{$pageLimit}
-
- ")->queryAll();
- $return['pages']=$pages;
- $return['dataList']=$data;
- return $return;
- }
- public function getAllUser(){
- $data = $this->getDbConnection()->createCommand("
- select user_id,user_name,real_name,sex,role,update_time,status
- from assist_user
- where role=1 and status=1
- order by user_id desc
-
- ")->queryAll();
- return $data;
- }
- public function getAllUserByLimit($condition){
- $sql="select user_id,user_name,real_name,sex,role,update_time,status
- from assist_user ";
- $where=array();
- $where[]="role=1 ";
- $where[]="status=1 ";
- if($condition){
- $where[]=$condition;
- }
- $sql.=" where ".implode(' and ',$where);
- $data = $this->getDbConnection()->createCommand($sql)->queryAll();
- return $data;
- }
- }
|