當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model::where方法代碼示例

本文整理匯總了PHP中think\Model::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model::where方法的具體用法?PHP Model::where怎麽用?PHP Model::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在think\Model的用法示例。


在下文中一共展示了Model::where方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: edit

 public function edit($id)
 {
     $model = new Model('Link');
     $data = $model->find($id);
     if (empty($data)) {
         $this->error('鏈接不存在');
     }
     if (IS_POST) {
         $name = I('name');
         $link = I('link');
         $status = I('status', 1);
         $sort = I('sort', 0);
         if (empty($name)) {
             $this->error('網站名稱不能為空');
         }
         if (empty($link)) {
             $this->error('網站鏈接不能為空');
         }
         $data = array('name' => $name, 'link' => $link, 'status' => $status, 'sort' => $sort);
         if (false === $model->where(array('linkId' => $id))->save($data)) {
             $this->error('編輯失敗');
         } else {
             $this->success('編輯成功', U('admin/link/index'));
         }
     } else {
         $this->assign('data', $data);
         $this->display('post');
     }
 }
開發者ID:xialeistudio,項目名稱:thinkphp-inaction,代碼行數:29,代碼來源:LinkController.class.php

示例2: checkVerfiyCode

 function checkVerfiyCode()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $phone = $param['phone'];
     $verfiycode = $param['verfiycode'];
     if (empty($phone)) {
         err_ret(-205, 'lack of param', '缺少參數');
     }
     if (empty($verfiycode)) {
         err_ret(-205, 'lack of param', '缺少參數');
     }
     //萬能驗證碼
     if ($verfiycode == '0228') {
         http_ret(0, 'verify code is correct', '驗證碼正確');
     }
     $model = new Model('verify_tmp');
     $condition['phone'] = $phone;
     $condition['verifycode'] = $verfiycode;
     $result = $model->where($condition)->select();
     if (count($result) <= 0) {
         err_ret(-307, 'verfiy code is incorrect', '驗證碼不正確');
     }
     $time = time() - $result[0]['gen_time'];
     if ($time > 5 * 60) {
         err_ret(-308, 'verify code is invalid', '驗證碼已過期');
     }
     if ($verfiycode == $result[0]['verifycode']) {
         http_ret(0, 'verify code is correct', '驗證碼正確');
     } else {
         err_ret(-307, 'verfiy code is incorrect', '驗證碼不正確');
     }
 }
開發者ID:kaka2007,項目名稱:xplan,代碼行數:32,代碼來源:VerifyController.class.php

示例3: send

 /**
  * 發送驗證碼
  * @param string $mobile 手機號
  * @return boolean 是否成功
  */
 public function send($mobile)
 {
     //驗證碼每天手機號最大數量
     if (parent::where(array('mobile' => $mobile, 'create_time' => array('gt', time())))->count() > (int) C('sms.mobile_day_max')) {
         $this->error = '手機號 ' . $mobile . ' 已超過每天發送驗證碼最大數量';
         return false;
     }
     //驗證碼每天ip最大數量
     if (parent::where(array('ip' => get_client_ip(), 'create_time' => array('gt', time())))->count() > (int) C('sms.ip_day_max')) {
         $this->error = 'ip ' . get_client_ip() . ' 已超過每天發送驗證碼最大數量';
         return false;
     }
     //驗證碼每天ip最大數量
     if (time() - parent::where(array('mobile' => $mobile))->order('id desc')->getField('create_time') < (int) C('sms.send_wait_time')) {
         $this->error = '發送間隔過於頻繁';
         return false;
     }
     if (!($data = $this->create((new Sms())->send($mobile)))) {
         return false;
     }
     if ($data['status'] != '0') {
         $this->error = (new Sms())->getError($data['code']);
         return false;
     }
     return parent::add($data);
 }
開發者ID:sw373740570,項目名稱:Thinkphp,代碼行數:31,代碼來源:SmsModel.class.php

示例4: read

 public function read($id)
 {
     $map['id'] = (int) $id;
     if ($map['id'] <= 0) {
         $this->error('請選擇商品');
     }
     $model = new Model('Goods');
     $info = $model->where($map)->find();
     $store_M = new Model('Store');
     $store_info = $store_M->find($info['store_id']);
     $this->assign('store_info', $store_info);
     //所屬店鋪
     $cate_M = new CategoryModel();
     if ($info['cate_id'] > 0) {
         $info['cate_name'] = $cate_M->where('id=' . $info['cate_id'])->getField('cate_name');
     } else {
         $info['cate_name'] = '無分類';
     }
     $map = array('store_id' => $info['store_id'], 'status' => 1);
     $cate_tree = $cate_M->ztreeArr($map);
     //ztree json
     $tmp = array(array('id' => null, 'pId' => 0, 'name' => '無分類'));
     $cate_tree = array_merge(array(array('id' => 0, 'pId' => 0, 'name' => '無分類', 'open' => true)), $cate_tree);
     //$tmp + $cate_tree;
     $cate_tree = json_encode($cate_tree);
     $this->assign('tree_json', $cate_tree);
     //ztree json
     $this->assign('info', $info);
     //商品信息
     cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']);
     $this->display();
 }
開發者ID:hcpzhe,項目名稱:foodorder,代碼行數:32,代碼來源:GoodsController.class.php

示例5: getPlanDetail

 function getPlanDetail()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     init_verify_token($token);
     $pid = $param['pid'];
     //$pid = 1;
     if (empty($pid)) {
         err_ret(-205, 'lack of param', '缺少參數');
     }
     //獲取計劃的基本信息
     $plan_model = new Model('plan');
     $condition['id'] = $pid;
     $result = $plan_model->where($condition)->select();
     //獲取計劃的介紹信息
     $plan_intro_model = new Model('plan_intro');
     unset($condition);
     $condition['pid'] = $pid;
     $result_intro = $plan_intro_model->where($condition)->select();
     //查詢計劃對應的教練的信息(未排序)
     // $sql_coach = "SELECT coachid,name,duration,header,type,price FROM user_info,(
     //     SELECT coachid FROM plan,plan_coach WHERE plan.id=$pid AND plan.id=plan_coach.pid
     // ) AS t WHERE t.coachid=user_info.id";
     //查詢計劃對應的教練的信息(已排序)
     $sql_coach = "SELECT coachid,name,duration,header,type,price ,score FROM user_info,(\n            SELECT coachid FROM plan,plan_coach WHERE plan.id={$pid} AND plan.id=plan_coach.pid AND plan_coach.status=0\n        ) AS t WHERE t.coachid=user_info.id ORDER BY score DESC";
     $model_coach = new Model();
     $result_coach = $model_coach->query($sql_coach);
     $data['errno'] = 0;
     $data['coverimg'] = $result[0]['coverimg'];
     $data['title'] = $result[0]['title'];
     $data['peoplenumber'] = $result[0]['peoplenumber'];
     $data['coach_list'] = $result_coach;
     $data['intro_list'] = $result_intro;
     echo json_encode($data);
 }
開發者ID:kaka2007,項目名稱:xplan,代碼行數:35,代碼來源:PlanController.class.php

示例6: loginCheck

 /**
  * 登錄驗證
  * @param $loginArr
  * @return $arr
  */
 public function loginCheck($loginArr)
 {
     $User = new Model('user');
     $array['US_name'] = $loginArr['US_name'];
     //設置用戶等級為管理員
     $array['Us_level'] = 2;
     $result = $User->where($array)->select();
     $arr = array();
     $arr['status'] = 0;
     if ($result != null && count($result) == 1) {
         if (strcmp(md5($loginArr['password']), $result[0]['password']) == 0) {
             //登陸成功
             $arr['status'] = 1;
             $arr['content'] = '驗證成功!';
             return $arr;
         } else {
             //登陸失敗(密碼錯誤)
             $arr['content'] = '密碼錯誤!';
             return $arr;
         }
     } else {
         $arr['content'] = '用戶名不存在!';
         return $arr;
     }
 }
開發者ID:ljhchshm,項目名稱:Recruitment-,代碼行數:30,代碼來源:UserModel.class.php

示例7: checkCoachMaxUsers

 function checkCoachMaxUsers()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $token = $param['xtoken'];
     // init_verify_token($token);
     $coachid = $param['coachid'];
     // $coachid = 53;
     if (empty($coachid)) {
         err_ret(-205, 'lack of param', '缺少參數');
     }
     //判斷教練的客戶是否超過10個
     $model = new Model();
     $sql_user = 'SELECT DISTINCT uid  FROM my_plan WHERE coachid=' . $coachid;
     $result_user = $model->query($sql_user);
     $studentNums = M("user_info")->where("type=1 and id={$coachid}")->getField("studentnums");
     if (count($result_user) >= $studentNums) {
         $model_user = new Model('user_info');
         $save_data['status'] = 1;
         $where_data['id'] = $coachid;
         $where_data['type'] = 1;
         $model_user->where($where_data)->save($save_data);
         $data['errno'] = 0;
         $data['is_max'] = 1;
         $data['coachid'] = $coachid;
         echo json_encode($data);
     } else {
         $data['errno'] = 0;
         $data['is_max'] = 0;
         $data['coachid'] = $coachid;
         echo json_encode($data);
     }
 }
開發者ID:kaka2007,項目名稱:xplan,代碼行數:32,代碼來源:OrderController.class.php

示例8: where

 public function where($map, $parse = null)
 {
     if (!$this->not_belongs_to_company && !$map['id']) {
         $map["company_id"] = get_current_company_id();
     }
     return parent::where($map, $parse);
 }
開發者ID:npk,項目名稱:ones,代碼行數:7,代碼來源:CommonModel.class.php

示例9: updateDeviceToken

 function updateDeviceToken()
 {
     $param = json_decode(file_get_contents('php://input'), true);
     $xtoken = $param['xtoken'];
     init_verify_token($xtoken);
     $uid = $param['uid'];
     if (empty($uid)) {
         err_ret(-205, 'lack of param', '缺少參數');
     }
     $device_token = $param['device_token'];
     if (empty($device_token)) {
         err_ret(-205, 'lack of param', '缺少參數');
     }
     //設備類型 1安卓手機  2蘋果手機
     $type = $param['type'];
     if ($type != 1 && $type != 2) {
         err_ret(-205, 'param is error', '參數錯誤');
     }
     $model = new Model('apns_user');
     $where_data['uid'] = $uid;
     $result = $model->where($where_data)->select();
     if (count($result) > 0) {
         //如果已經有了deviceToken
         $old_type = $param[0]['type'];
         $old_device_token = $param[0]['device_token'];
         if ($old_device_token != $device_token) {
             $type = $old_type == 1 ? 2 : 1;
             $condition['uid'] = $uid;
             $save_data['device_token'] = $device_token;
             $save_data['type'] = $type;
             $model->where($condition)->save($save_data);
         }
     } else {
         $add_data['device_token'] = $device_token;
         $add_data['uid'] = $uid;
         $add_data['type'] = $type;
         $result = $model->add($add_data);
     }
     $data['errno'] = 0;
     $data['uid'] = $uid;
     $data['type'] = $type;
     $data['device_token'] = $device_token;
     echo json_encode($data);
 }
開發者ID:kaka2007,項目名稱:xplan,代碼行數:44,代碼來源:UmengpushController.class.php

示例10: checkAccount

 public function checkAccount($account)
 {
     $model = new Model('Admin');
     $status = $model->where('account="' . trim($account) . '"')->getField('id');
     if (intval($status) > 0) {
         return false;
     } else {
         return true;
     }
 }
開發者ID:sunrain520,項目名稱:WYmanage,代碼行數:10,代碼來源:AdminModel.class.php

示例11: checkQq

 /**
  * 檢查該QQ是否已被注冊
  * @param string qq 用戶提交的qq字段
  * @access protected
  * */
 protected function checkQq($qq)
 {
     $mo = new Model();
     $mo->table('__USERS__');
     if (empty($mo->where(array('qq' => $qq))->find())) {
         return true;
     } else {
         return false;
     }
 }
開發者ID:pea3nut,項目名稱:wa,代碼行數:15,代碼來源:UsersModel.class.php

示例12: get_num_odr

function get_num_odr($oid)
{
    $model = new Model('OrderGoods');
    $list = $model->where('order_id=' . $oid)->select();
    $num = 0;
    foreach ($list as $row) {
        $num += $row['quantity'];
    }
    return $num;
}
開發者ID:hcpzhe,項目名稱:foodorder,代碼行數:10,代碼來源:function.php

示例13: init_verify_token

function init_verify_token($token)
{
    if ($token == '') {
        err_ret(-205, 'lack of param xtoken', '缺少xtoken參數');
    }
    $model = new Model('user_info');
    $condition['xtoken'] = $token;
    $result = $model->where($condition)->select();
    if (count($result) <= 0) {
        err_ret(-505, 'tokan is invalid', 'token 失效');
    }
}
開發者ID:kaka2007,項目名稱:xplan,代碼行數:12,代碼來源:common.php

示例14: lists

 /**
  * 列表
  */
 public function lists($status = null)
 {
     $model = new GoodsModel();
     $map = array();
     $status_view = array('default' => '所有', 'del' => '已刪除', 'forbid' => '禁用', 'allow' => '正常');
     //查詢條件 處理
     $map['store_id'] = STID;
     $store_M = new Model('Store');
     $store_info = $store_M->find(STID);
     if (empty($store_info)) {
         $this->error('店鋪不存在');
     }
     $this->assign('store_info', $store_info);
     //店鋪信息
     if (isset($status) && key_exists($status, GoodsModel::$mystat)) {
         //指定查詢狀態
         $map['status'] = GoodsModel::$mystat[$status];
         $now_status = $status_view[$status];
     } else {
         $map['status'] = array('EGT', 0);
         //默認查詢狀態為未刪除的數據
         $now_status = $status_view['default'];
     }
     /******************/
     $list = $this->_lists($model, $map);
     $this->assign('list', $list);
     //列表
     $this->assign('now_status', $now_status);
     //當前頁麵篩選的狀態
     if (!empty($list)) {
         $cate_M = new Model('Category');
         $cate_ids = field_unique($list, 'cate_id');
         //列表中用到的會員ID
         $map = array('id' => array('in', $cate_ids));
         $catelist = $cate_M->where($map)->getField('id,cate_name');
         $this->assign('catelist', $catelist);
         //列表用到的分類, ID為key索引
     }
     /*****用於添加商品的商品分類樹**/
     $catetreemap = array('store_id' => STID, 'status' => '1');
     //隻要狀態正常商品分類
     $cate_M = new CategoryModel();
     $cate_tree = $cate_M->ztreeArr($catetreemap);
     $cate_tree = array_merge(array(array('id' => 0, 'pId' => 0, 'name' => '無分類', 'open' => true)), $cate_tree);
     $cate_tree = json_encode($cate_tree);
     $this->assign('tree_json', $cate_tree);
     //category ztree json
     // 記錄當前列表頁的cookie
     cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']);
     $this->display();
 }
開發者ID:hcpzhe,項目名稱:foodorder,代碼行數:54,代碼來源:GoodsController.class.php

示例15: delete

 public function delete()
 {
     $id = I('id');
     if (empty($id)) {
         $this->error('缺少參數');
     }
     $this->checkLogin();
     $model = new Model('Message');
     $result = $model->where(array('message_id' => $id, 'user_id' => session('user.userId')))->find();
     if (!$result) {
         $this->error('刪除失敗');
     }
     $this->success('刪除成功', U('index'));
 }
開發者ID:xialeistudio,項目名稱:thinkphp-inaction,代碼行數:14,代碼來源:IndexController.class.php


注:本文中的think\Model::where方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。