find(array('asc' => 'userid', 'limit' => $limit, 'asArray' => true)); } public function getResultbysort($sort = '',$limit) { if($sort == 'id' || $sort == ''){ return $this->find(array('asc' => 'userid', 'limit' => $limit, 'asArray' => true)); }elseif($sort == 'class') { $sql = 'SELECT `kt_user`. * , count( `kt_class_user`.userid ) FROM `kt_user` LEFT JOIN `kt_class_user` ON `kt_user`.userid = `kt_class_user`.userid GROUP BY `kt_user`.userid ORDER BY count( `kt_class_user`.userid ) DESC , userid ASC LIMIT ' . $limit; $query = Doo::db ()->query ( $sql ); $result = $query->fetchAll (); return $result; }elseif($sort == 'cost') { $sql = 'SELECT `kt_user`. * , sum( `kt_class_user`.price ) FROM `kt_user` LEFT JOIN `kt_class_user` ON `kt_user`.userid = `kt_class_user`.userid GROUP BY `kt_user`.userid ORDER BY sum( `kt_class_user`.price ) DESC , userid ASC LIMIT ' . $limit; $query = Doo::db ()->query ( $sql ); $result = $query->fetchAll (); return $result; } } public function getNamebyId($id){ return $this->getOne(array('select' => 'username,realname,idcard', 'where' => 'userid='.$id, 'asArray' => TRUE)); } public function getuserbyId($id){ return $this->getOne(array('where' => 'userid='.$id, 'asArray' =>TRUE)); } public function getUserMsgbySearch($search){ return $this->getOne(array('where' => 'username="'.$search.'" or realname="'.$search.'"', 'asArray' => TRUE)); } public function getUserMsgbyidcard($search){ return $this->getOne(array('where' => 'idcard like "%'.$search.'"', 'asArray' => TRUE)); } public function getRowByEmail($email){ return $this->getOne(array('where' => 'useremail="'.$email.'"', 'asArray' => TRUE)); } public function getRowByMobile($mobile){ return $this->getOne(array('where' => 'mobile="'.$mobile.'"', 'asArray' => TRUE)); } public function getRowByUsername($username){ return $this->getOne(array('where' => 'username="'.$username.'"', 'asArray' => TRUE)); } public function getRowByUserPass($data){ return $this->getOne(array('where' => 'username="'.$data['name'].'" and password="'.$data['password'].'"')); } }