當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。