当前位置: 首页>>代码示例>>PHP>>正文


PHP UserModel::where方法代码示例

本文整理汇总了PHP中UserModel::where方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::where方法的具体用法?PHP UserModel::where怎么用?PHP UserModel::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserModel的用法示例。


在下文中一共展示了UserModel::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * 用户资料管理   首页
  */
 function index()
 {
     //分页类
     import('ORG.Util.Page');
     //搜索栏
     $keyword = trim($_POST['keyword']);
     if (is_numeric($keyword)) {
         $where['id'] = array('eq', $keyword);
     } else {
         $where['username'] = array('like', '%' . $keyword . '%');
     }
     //切换用户状态
     $change_pub = trim($_POST['change_published']);
     if ($change_pub) {
         $where['active'] = array('eq', $change_pub);
     }
     //传值在前台判断
     $this->assign('change_pub', $change_pub);
     //查询数据并进行分页
     $users = new UserModel();
     $counts = $users->where($where)->count();
     $page = new Page($counts, C('PAGESIZE'));
     $show = $page->show();
     $this->assign('show', $show);
     $list = $users->where($where)->order('id')->limit($page->firstRow . ',' . $page->listRows)->select();
     $this->assign('user_lists', $list);
     $this->display();
 }
开发者ID:omusico,项目名称:AndyCMS,代码行数:31,代码来源:UserAction.class.php

示例2: POST_numberAction

 /**
  * 分析学号所在学校
  * @method POST_numberAction
  * @author NewFuture
  */
 public function POST_numberAction()
 {
     if (Input::post('number', $number, 'card')) {
         echo "hello world";
         /*排除学校*/
         if (Input::post('black', $black)) {
             $this->parse($black);
         }
         /*限定学校*/
         if (Input::post('white', $white)) {
             $this->parse($white);
         }
         if ($schools = School::guess($number, $black, $white)) {
             if ($reg = UserModel::where('number', $number)->select('sch_id')) {
                 foreach ($reg as $user) {
                     $schools[$user['sch_id']] = 0;
                 }
             }
             $this->response(1, $schools);
         } else {
             $this->response(0, '无相关学校,请检查学号是否正确');
         }
     } else {
         $this->response(0, '学号格式有误');
     }
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:31,代码来源:School.php

示例3: login

 public function login($user, $password)
 {
     $md5 = md5($password);
     $user = UserModel::where('user', '=', $user)->where('password')->get();
     if ($user) {
         $session = new \RKA\Session();
         $session->set('auth-identity', array('id' => $user->id, 'user' => $user->user, 'password' => $user->password, 'profile' => $user->name, 'group' => $user->group));
     }
 }
开发者ID:mrcoco,项目名称:webtool,代码行数:9,代码来源:Auth.php

示例4: testAddPraiseSuccess

 /**
  * @dataProvider provideValidatePraiseList
  */
 public function testAddPraiseSuccess($moodContent, $userPhone)
 {
     $userTable = new UserModel();
     $moodTable = new MoodListModel();
     $praiseTable = new PraiseMoodModel();
     $findUser['phone'] = $userPhone;
     $user = $userTable->where($findUser)->find();
     $findMood['content'] = $moodContent;
     $mood = $moodTable->where($findMood)->find();
     $this->assertTrue(is_numeric($praiseTable->addPraise($user['id'], $mood['id'])));
 }
开发者ID:chen8840,项目名称:LMJ-s-project,代码行数:14,代码来源:MoodListViewModelTest.php

示例5: GET_emailAction

 /**
  * 获取用户真实手机
  * GET /user/1/email
  * @method GET_infoAction
  * @param  integer        $id [description]
  * @author NewFuture
  */
 public function GET_emailAction($id = 0)
 {
     $pid = $this->authPrinter();
     if (TaskModel::where('use_id', $id)->where('pri_id', $pid)->get('id')) {
         $email = UserModel::where('id', '=', $id)->get('email');
         $email = $email ? Encrypt::decryptEmail($email) : null;
         $this->response(1, $email);
     } else {
         $this->response(0, '此同学未在此打印过');
     }
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:18,代码来源:User.php

示例6: post_phoneAction

 /**
  * 绑定用户手机
  * @method post_phoneAction
  * @return [type]           [description]
  * @author NewFuture
  */
 public function post_phoneAction()
 {
     $uid = $this->auth();
     if (!Input::post('phone', $phone, 'phone')) {
         $this->response(0, '无效手机号');
     } elseif (UserModel::where('id', '=', $uid)->get('phone')) {
         $this->response(0, '此接口不允许修改手机号');
     } elseif (UserModel::savePhone($phone)) {
         $this->response(1, '修改成功');
     } else {
         $this->response(0, '修改出错');
     }
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:19,代码来源:Card.php

示例7: postLogin

 public function postLogin()
 {
     $credentials = \Input::only('email', 'password');
     $user = UserModel::where('email', \Input::get('email'))->first();
     // dd($user);
     if ($user and \Hash::check(\Input::get('password'), $user->password)) {
         Auth::login($user);
         flash('welcome in ' . auth()->user()->username, 'success');
         return redirect('/user/');
     } else {
         flash('unable to login', 'danger');
         return redirect('/user/login');
     }
 }
开发者ID:NablusTechMeetups,项目名称:web,代码行数:14,代码来源:UserController.php

示例8: GET_infoAction

 /**
  * 分享文件详细信息
  * GET /share/1
  * @method GET_info
  * @author NewFuture
  * @todo 预览等,权限
  */
 public function GET_infoAction($id = 0)
 {
     $uid = $this->auth();
     if ($share = ShareModel::find($id)) {
         $share['user'] = $share['anonymous'] ? '不愿透露姓名的同学' : UserModel::where('id', $share['use_id'])->get('name');
         if ($uid != $share['use_id']) {
             unset($share['use_id']);
             unset($share['fil_id']);
         }
         $this->response(1, $share);
     } else {
         $this->response(0, '该分享不存在');
     }
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:21,代码来源:Share.php

示例9: check

 /**
  * 验证用户名,密码是否正确并存入SESSION中
  */
 function check()
 {
     //得到用户名,密码,验证码
     $username = trim($_POST['username']);
     $password = trim($_POST['password']);
     $verify = trim($_POST['verify']);
     if ($_SESSION['verify'] != strtoupper($verify)) {
         $this->error('验证码出错');
     }
     //实例化用户模型
     $user = new UserModel();
     $userinfo = $user->getByUsername($username);
     if (count($userinfo) > 0) {
         if ($userinfo['password'] != md5($password)) {
             $this->error('密码错误,请重试');
         } else {
             if ($userinfo['active'] != 1) {
                 $this->error('账户未激活,请联系管理员');
             } else {
                 //得到当前时间
                 $current_time = date('Y-m-d H:i:s', time());
                 //判断用户写入
                 $where['username'] = $username;
                 //如果用户登录进来了,把登录时间写进数据库login_record中。
                 $log_record = new LoginRecordModel();
                 $log['login_date'] = $current_time;
                 $log['email'] = $userinfo['email'];
                 $log['username'] = $userinfo['username'];
                 $return_id = $log_record->where($where)->add($log);
                 //将插入返回的主键ID 保存在SESSION中,以便在用户退出的时候更新退出时间
                 $_SESSION['record_id'] = $return_id;
                 //将用户放进SESSION里面,并且更新用户最后登陆时间
                 $_SESSION['username'] = trim($username);
                 $data['last_login_date'] = $current_time;
                 $user->where($where)->save($data);
                 $this->redirect('Manage/index');
             }
         }
     } else {
         $this->error('您输入的用户名不存在');
     }
 }
开发者ID:omusico,项目名称:AndyCMS,代码行数:45,代码来源:IndexAction.class.php

示例10: login

 /**
  * 登录函数
  * @method login
  * @access private
  * @author NewFuture[newfuture@yunyin.org]
  * @param  [string]   $password    [md5密码]
  * @return [bool/int] [用户id]
  */
 private function login($number, $password, $sch_id = null)
 {
     $conditon = ['number' => $number];
     //指定学校
     $sch_id and $conditon['sch_id'] = $sch_id;
     $users = UserModel::where($conditon)->select('id,password,sch_id,name');
     if (empty($users)) {
         /*未注册*/
         return null;
     } else {
         /*验证结果*/
         $password = Encrypt::encryptPwd($password, $number);
         $reg_schools = [];
         foreach ($users as &$user) {
             if ($user['password'] == $password) {
                 /*登录成功*/
                 $user['number'] = $number;
                 $token = Auth::token($user);
                 $sessionid = Session::start();
                 unset($user['password']);
                 Session::set('user', $user);
                 Cookie::set('token', $token);
                 // $user['school'] = SchoolModel::getName($user['sch_id']);
                 $result = ['sid' => $sessionid, 'user' => $user, 'msg' => '登录成功!', 'token' => $token];
                 $this->response(1, $result);
                 return true;
             } else {
                 /*验证失败*/
                 $sid = $user['sch_id'];
                 $reg_schools[$sid] = School::getAbbr($sid);
             }
         }
         $this->reg_schools = $reg_schools;
         return false;
     }
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:44,代码来源:Auth.php

示例11: editpp

 public function editpp()
 {
     if (Input::hasFile('file')) {
         //upload profile picture and set filename to a variale to save to db
         $user = Session::get('sess_api_user_arr');
         $get_userid = $user['userid'];
         $file = Input::file('file');
         $filename = bin2hex(mcrypt_create_iv(10, MCRYPT_DEV_URANDOM)) . "" . $get_userid . "-" . $file->getClientOriginalName() . "_" . rand(1, 100);
         $file->move('public/profilepics', $filename);
         $picture = $filename;
         $user = UserModel::where('userid', $get_userid);
         $user->update(['picture' => $picture]);
         /*
         This part needs to trash the old session that holds the UserModel row being
         processed during login. 
         */
         Session::forget('sess_api_user_arr');
         //Trash the old session
         //Getting the newly updated UserModel row and save it to a new session
         $user = UserModel::where('userid', '=', $get_userid)->first();
         //Get updated row in database after upload picture
         Session::put('sess_api_user_arr', $user);
         //Save session similar to the session name of before's session.
         //return Redirect::intended('http://lock-lockitproject.rhcloud.com/profile');
         $response['status'] = "success";
         $response['message'] = "Profile picture updated!";
         $response['userid'] = $user['userid'];
         $response['firstname'] = $user['firstname'];
         $response['lastname'] = $user['lastname'];
         $response['username'] = $user['username'];
         $response['password'] = $user['password'];
         $response['email'] = $user['email'];
         $response['contact'] = $user['contact'];
         $response['accttype'] = $user['accttype'];
         $response['picture'] = $user['picture'];
         $response['occupation'] = $user['occupation'];
         $response['gender'] = $user['gender'];
         $response['birthday'] = $user['birthday'];
         $response['city'] = $user['city'];
         $response['home'] = $user['home'];
         echo json_encode($response);
     } else {
         $response['status'] = "failed";
         $response['message'] = "Profile picture not updated!";
         echo json_encode($response);
     }
 }
开发者ID:brianmadmaxsy,项目名称:Lock_Project,代码行数:47,代码来源:LockAPIController.php

示例12: POST_emailAction

 /**
  * 绑定邮箱,发送邮箱验证信息
  * PUT /user/1/email {email:"xx@mail.yunyin.org"}
  * @method GET_infoAction
  * @param  integer        $id [description]
  * @author NewFuture
  */
 public function POST_emailAction($id = 0)
 {
     $id = $this->auth($id);
     $response['status'] = 0;
     if (!Input::post('email', $email, 'email')) {
         $response['info'] = '无效邮箱';
     } elseif (UserModel::getByEmail($email)) {
         $response['info'] = '已经绑定过用户';
     } elseif (!Safe::checkTry('bind_email_' . $id)) {
         $response['info'] = '发送次数过多,12小时之后重试';
     } else {
         /*生成验证码*/
         $name = UserModel::where('id', $id)->get('name');
         $code = ['use_id' => $id, 'type' => 1];
         $Code = new Model('code');
         $Code->delete($code);
         $code['code'] = $id . '_' . Random::word(16);
         $code['content'] = $email;
         /*发送邮件*/
         if ($Code->insert($code) && Mail::sendVerify($email, $code['code'], $name)) {
             $response['status'] = 1;
             $response['info'] = '验证邮件成功发送至:' . $email;
         } else {
             $response['info'] = '邮件发送出错[最多还可重发' . Config::get('try.times') . '次]';
         }
     }
     $this->response = $response;
 }
开发者ID:derek-chow,项目名称:YunYinService,代码行数:35,代码来源:User.php

示例13: editpp

 public function editpp()
 {
     if (Input::hasFile('file')) {
         //upload profile picture and set filename to a variale to save to db
         $user = Session::get('sess_user_arr');
         $get_userid = $user['userid'];
         $file = Input::file('file');
         $filename = bin2hex(mcrypt_create_iv(10, MCRYPT_DEV_URANDOM)) . "" . $user['username'] . "-" . $file->getClientOriginalName() . "_" . rand(1, 100);
         $file->move('public/profilepics', $filename);
         $picture = $filename;
         $user = UserModel::where('userid', $user['userid']);
         $user->update(['picture' => $picture]);
         /*
         This part needs to trash the old session that holds the UserModel row being
         processed during login. 
         */
         Session::forget('sess_user_arr');
         //Trash the old session
         //Getting the newly updated UserModel row and save it to a new session
         $user = UserModel::where('userid', '=', $get_userid)->first();
         //Get updated row in database after upload picture
         Session::put('sess_user_arr', $user);
         //Save session similar to the session name of before's session.
         return Redirect::intended('/profile');
     } else {
         //set picture to null
         return Redirect::intended('/profile');
     }
 }
开发者ID:brianmadmaxsy,项目名称:Lock_Project,代码行数:29,代码来源:LockMainController.php

示例14: where

        $this->order = "ORDER BY " . $order;
        return $this;
    }
    function where($where)
    {
        $this->where = "WHERE " . $where;
        return $this;
    }
    function limit($index, $limit = 0)
    {
        $this->limit = "LIMIT " . $index;
        if ($limit) {
            $this->limit .= ",{$limit}";
        }
        return $this;
    }
    function select()
    {
        if (empty($this->tableName)) {
            $this->tableName = str_replace("Model", "", __CLASS__);
            //如果表名不指定,则获取类名
        }
        $selectSql = "SELECT {$this->field}\n                         FROM `{$this->tableName}`\n                         {$this->where}\n                         {$this->order}\n                         {$this->limit}";
        //构造SQL语句模版串
        echo $selectSql;
        //return mysql_query($selectSql);  执行拼接后的SQL语句
    }
}
$user = new UserModel();
$user->where("`user` = 1")->order("`user` DESC")->limit(5)->select();
开发者ID:EdenChan,项目名称:Instances,代码行数:30,代码来源:link_sql.php

示例15: moneysave

 public function moneysave()
 {
     if (!IS_POST) {
         $this->message2('非法操作!', __APP__ . '/Admin');
     }
     $user_model = new UserModel();
     $user_account = new Model('account_log');
     $id = I('id', 0);
     if ($id <= 0) {
         $this->message('未指定会员信息!', __URL__ . '/index');
     }
     $user = $user_model->where('id=' . $id)->find();
     if (empty($user)) {
         $this->message('未找到指定会员信息!', __URL__ . '/index');
     }
     $account_type = I('account_type', 1);
     $bg_type = I('bg_type', 1);
     $addmoney = I('addmoney', 0);
     $reason = I('reason', '');
     if ($addmoney <= 0) {
         $this->message('请填写变动金额!', __URL__ . '/addmoney/id/' . $id);
     }
     if ($reason == '') {
         $this->message('请填写变更原因!', __URL__ . '/addmoney/id/' . $id);
     }
     if ($account_type == 1) {
         if ($bg_type == 1) {
             $money = $user['money'] + $addmoney;
             $content = '增加账户余额' . $addmoney;
         } else {
             $money = $user['money'] - $addmoney;
             $content = '减少账户余额' . $addmoney;
             $addmoney = 0 - $addmoney;
         }
         if ($money < 0) {
             $this->message('该人账户可用余额已不足以冲减!', __URL__ . '/addmoney/id/' . $id);
         }
         $data['money'] = $money;
     } else {
         if ($account_type == 2) {
             if ($bg_type == 1) {
                 $money = $user['refer_money'] + $addmoney;
                 $content = '增加可用佣金' . $addmoney;
             } else {
                 $money = $user['refer_money'] - $addmoney;
                 $content = '减少可用佣金' . $addmoney;
                 $addmoney = 0 - $addmoney;
             }
             $data['refer_money'] = $money;
             if ($money < 0) {
                 $this->message('该人账户可用佣金已不足以冲减!', __URL__ . '/addmoney/id/' . $id);
             }
         }
     }
     $user_model->startTrans();
     if (false !== $user_model->where('id=\'' . $id . '\'')->data($data)->save()) {
         $account_log['user_id'] = $id;
         $account_log['stage'] = 'admin';
         $account_log['money'] = $addmoney;
         $account_log['comm'] = $reason;
         $account_log['addtime'] = $this->getDate();
         if ($account_type == 1) {
             $account_log['remain_money'] = $money;
             $account_log['remain_refer_money'] = $user['refer_money'];
         } else {
             if ($account_type == 2) {
                 $account_log['remain_money'] = $user['money'];
                 $account_log['remain_refer_money'] = $money;
             }
         }
         if (false !== $user_account->data($account_log)->add()) {
             $user_model->commit();
             $content = '对会员' . $user['username'] . $content . ',若为本人操作,请忽略该条提醒!';
             send_fetion($content);
             $this->message('操作成功', __URL__ . '/index');
         } else {
             $user_model->rollback();
             $this->message('操作失败1:' . $user_account->getError(), __URL__ . '/addmoney/id/' . $id);
         }
     } else {
         $user_model->rollback();
         $this->message('操作失败2:' . $user_account->getDbError());
     }
 }
开发者ID:kwdwkiss,项目名称:kongbao8,代码行数:84,代码来源:UserAction.class.php


注:本文中的UserModel::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。