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


PHP Model::table方法代碼示例

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


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

示例1: regist

 /**
  * 注冊
  * @param array $data 注冊數據
  */
 public function regist($data)
 {
     // 將用戶信息添加到User表中
     $tranDb = new Model();
     $tranDb->startTrans();
     $username = $data['username'];
     $result = $tranDb->table('world_user')->where("username = '{$username}'")->find();
     if ($result == null) {
         $user_info = array('username' => $username, 'password' => $data['password'], 'session' => md5(time() . $username), 'modify_time' => time(), 'last_time' => time());
         $uid = $tranDb->table('world_user')->data($user_info)->add();
         $tranDb->commit();
         return 1;
         // 注冊用戶成功
     } else {
         return -1;
         // 用戶名已存在
     }
 }
開發者ID:xinliuruoxi,項目名稱:Ones-World,代碼行數:22,代碼來源:UserModel.class.php

示例2: 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

示例3: regist

 /**
  * 注冊
  * @param array $data 注冊數據
  */
 public function regist($data)
 {
     // 將用戶信息添加到User表中
     $tranDb = new Model();
     $tranDb->startTrans();
     $username = $data['username'];
     $result = $tranDb->table('west_user')->where("username = '{$username}'")->find();
     if ($result == null) {
         $user_info = array('username' => $username, 'password' => $data['password'], 'group' => 'user', 'status' => 0, 'modify_time' => time());
         $uid = $tranDb->table('west_user')->data($user_info)->add();
         if ($uid) {
             // 判斷公司是否存在
             $company_name = $data['company_name'];
             $result = $tranDb->table('west_company')->where("name = '{$company_name}'")->find();
             if ($result == null) {
                 $company_info = array('uid' => $user_id, 'name' => $data['company_name'], 'mail' => $data['company_mail'], 'tel' => $data['company_tel'], 'modify_time' => time());
                 $result = $tranDb->table('west_company')->data($company_info)->add();
                 if ($result) {
                     $tranDb->commit();
                     return 1;
                     // 注冊用戶成功
                 } else {
                     $tranDb->rollback();
                     return -4;
                     // 添加公司信息失敗
                 }
             } else {
                 $tranDb->rollback();
                 return -3;
                 // 公司名稱已存在
             }
         } else {
             $tranDb->rollback();
             return -2;
             // 添加用戶信息失敗
         }
     } else {
         return -1;
         // 用戶名已存在
     }
 }
開發者ID:Yin-Far,項目名稱:west,代碼行數:45,代碼來源:UserModel.class.php

示例4: touchCheck

 public function touchCheck()
 {
     $pub = Utility::sslTrimKey($this->platform['public_key']);
     $ret = "<biz_content>{$pub}</biz_content><success>true</success>";
     $dat = $this->client->encryptAndSign($ret, false, true);
     parent::touchCheck();
     $message = $this->parse($this->params['biz_content']);
     $rec = array();
     $rec['appid'] = $message['to'];
     $m = new Model();
     $m->table('__PLATFORM_ALIPAY__')->data($rec)->where("`id`='{$this->platform['id']}'")->save();
     exit($dat);
 }
開發者ID:devsnippet,項目名稱:microbuilder,代碼行數:13,代碼來源:Alipay.class.php

示例5: getNews

 function getNews($page, $page_size)
 {
     /*return $this->join('term_relationships ON post.ID = term_relationships.object_id ')
         ->where(array('post_type' => 'post','post_status'=>'publish')
        ->page($page, $page_size)
        ->order('post_date DESC')  
       ->select();  */
     $Model = new Model();
     return $Model->table('wp_posts')->join('wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id')->where(array('wp_posts.post_type' => 'post', 'wp_posts.post_status' => 'publish'))->where("wp_term_relationships.term_taxonomy_id = 1")->page($page, $page_size)->order('post_date DESC')->select();
     /* $Model = new Model();
        return $Model->query("SELECT * from wp_posts wp where wp.post_type = 'post' 
          and wp.post_status = 'publish' 
          join wp_term_relationships wtr where wp.ID = wtr.object_id and wtr.term_taxonomy_id = 1 ")->page($page, $page_size)
        ->order('post_date DESC')  ; */
 }
開發者ID:Phlen,項目名稱:yaowan,代碼行數:15,代碼來源:NewsListModel.class.php

示例6: saveSettings

 /**
  * 將配置項寫入數據庫, 一般預留給模塊封裝調用, 控製其中不應該直接調用
  * @param $moduleName string 模塊名稱
  * @param $settings array 配置項名稱
  * @return bool
  */
 public static function saveSettings($moduleName, $settings)
 {
     $moduleName = strtoupper($moduleName);
     $ds = array();
     foreach ($settings as $key => $value) {
         if (!empty($key)) {
             $key = strtoupper($key);
             $origKey = "{$moduleName}:{$key}";
             $ds[$origKey] = serialize($value);
         }
     }
     if (empty($ds)) {
         return false;
     }
     $m = new Model();
     foreach ($ds as $key => $value) {
         $rec = array();
         $rec['key'] = $key;
         $rec['value'] = $value;
         $m->table('__CORE_SETTINGS__')->add($rec, array(), true);
     }
     return true;
 }
開發者ID:vki,項目名稱:microbuilder,代碼行數:29,代碼來源:Utility.class.php

示例7: getAddon

 public static function getAddon($name, $fromDefineFile = false)
 {
     if ($fromDefineFile) {
         $path = MB_ROOT . "addons/{$name}/define.xml";
         if (is_file($path)) {
             $xml = file_get_contents($path);
             $addon = self::parseDefineFile($xml);
             if (is_error($addon)) {
                 return $addon;
             }
         } else {
             return error(-1, '不存在這個擴展或者擴展定義文件不存在');
         }
     } else {
         $condition = '`name`=:name';
         $pars = array();
         $pars[':name'] = $name;
         $m = new Model();
         $addon = $m->table('__EX_ADDONS__')->where($condition)->bind($pars)->find();
         if (empty($addon)) {
             return error(-1, '不存在這個擴展');
         }
     }
     if (!empty($addon)) {
         $addon['icon'] = __SITE__ . "addons/{$addon['name']}/icon.png";
     }
     return $addon;
 }
開發者ID:devsnippet,項目名稱:microbuilder,代碼行數:28,代碼來源:Addon.class.php

示例8: changeOrderStatus

 /**
  * 支付成功,改變訂單狀態
  * @param int $order_id
  * @return bool
  */
 public function changeOrderStatus($order_id)
 {
     $flag = false;
     if ($order_id) {
         $db = new Model();
         $flag = $db->table($this->_table)->where(['id' => $order_id])->save(['status' => 2]);
     }
     return $flag;
 }
開發者ID:xswolf,項目名稱:dc,代碼行數:14,代碼來源:OrderModel.class.php

示例9: test_db

 /**
  * 檢測數據庫連接,成功則輸出成功信息,失敗則報錯
  * @access public
  * */
 public function test_db()
 {
     $mo = new Model();
     $msg = $mo->table('wa_users')->getDbFields();
     echo '連接成功!';
 }
開發者ID:pea3nut,項目名稱:wa,代碼行數:10,代碼來源:ToolsController.class.php

示例10: uninstallAction

 public function uninstallAction()
 {
     $a = I('get.addon');
     if (empty($a)) {
         $this->error('訪問錯誤');
     }
     $addon = new Addon($a);
     Addon::autoload();
     $class = "Addon\\{$a}\\Api\\Application";
     if (class_exists($class)) {
         $instance = new $class();
         if (!empty($instance)) {
             $instance->addon = $addon;
             if (method_exists($instance, 'install')) {
                 $instance->uninstall();
             }
         }
     }
     $condition = '`name`=:name';
     $pars = array();
     $pars[':name'] = $a;
     $m = new Model();
     $m->table('__EX_ADDONS__')->where($condition)->bind($pars)->delete();
     $m->table('__EX_ADDON_ENTRIES__')->where('`addon`=:name')->bind($pars)->delete();
     $m->table('__RP_PROCESSORS__')->where('`from`=:name')->bind($pars)->delete();
     $m->table('__RP_REPLIES__')->where('`from`=:name')->bind($pars)->delete();
     $this->success('擴展卸載成功');
 }
開發者ID:devsnippet,項目名稱:microbuilder,代碼行數:28,代碼來源:ExtendController.class.php

示例11: get_order

 /**
  * 訂單詳情
  */
 public function get_order()
 {
     $order_no = isset($_POST['order_no']) ? htmlspecialchars($_POST['order_no']) : '';
     $mer_session_id = $_POST['mer_session_id'];
     $merchant_id = $this->session_handle->getsession_userid($mer_session_id);
     if (empty($order_no)) {
         $this->jsonUtils->echo_json_msg(4, '訂單ID為空...');
         exit;
     }
     $model = new Model();
     $arr = $model->table(C('DB_PREFIX') . "order as a ")->field("b.header,b.nick_name,a.member_id,a.service_name,a.id,a.order_no,a.addtime,b.mobile,a.cart_id,a.cart_data,a.reach_time,a.total_price,a.total_time,a.type,a.sub_id,a.sub_data,a.status,a.merchant_comment,a.member_comment,a.merchant_remark,a.member_remark,ifnull(a.fail_content,'') as fail_content,b.mobile")->join(C('DB_PREFIX') . "member as b on a.member_id = b.id")->where("a.order_no = {$order_no} and a.merchant_id = {$merchant_id} and a.merchant_del = 0")->find();
     //echo $model->getLastSql();
     if ($arr) {
         //獲取jid
         $jid = CommonController::getSystemUserid($arr['member_id'], 0);
         $cart = json_decode($arr['cart_data'], true);
         unset($arr['cart_data']);
         $arr['system_user_id'] = $jid;
         $arr['cart_model'] = $cart['cart_model'];
         $arr['reach_time'] = date('Y-m-d H:i:s', $arr['reach_time']);
         $arr['addtime'] = date('Y-m-d H:i:s', $arr['addtime']);
         $arr['header'] = imgUrl($arr['header']);
         // 商家是否評價
         if ($arr['status'] != 0) {
             // 未完成訂單 沒有評價
             if ($arr['merchant_comment'] > 0) {
                 $sql = "select a.desc,c.header,a.service_attitude,c.merchant_name as nick_name,from_unixtime(a.addtime,'%Y-%m-%d %H:%i:%s') as addtime\r\n\t        \t\tfrom " . C('DB_PREFIX') . "comment as a\r\n\t        \t\tleft join " . C('DB_PREFIX') . "merchant as c\r\n\t        \t\ton a.merchant_id=c.id\r\n\t        \t\twhere a.order_no={$arr['order_no']} and type=2 limit 1";
                 $arro = $this->dao->query($sql);
                 $arro[0]['header'] = imgUrl($arro[0]['header']);
                 $arr['merchant_comment_info'] = $arro[0];
             } else {
                 $arr['merchant_comment_info'] = '';
                 $arr['merchant_comment'] = '0';
             }
             // 用戶是否評論
             if ($arr['member_comment'] > 0) {
                 $sql = "select a.desc,c.header,c.nick_name,a.service_attitude,a.service_quality,a.merchant_setting,a.pics,from_unixtime(a.addtime,'%Y-%m-%d %H:%i:%s') as addtime\r\n\t\t        \tfrom " . C('DB_PREFIX') . "comment as a  \r\n\t\t        \tleft join " . C('DB_PREFIX') . "member as c \r\n\t\t        \ton a.member_id=c.id \r\n\t\t        \twhere a.order_no={$arr['order_no']} and type=0 limit 1";
                 $arro = $this->dao->query($sql);
                 $arro[0]['header'] = imgUrl($arro[0]['header']);
                 $arro[0]['pics'] = imgUrl(json_decode($arro[0]['pics'], true));
                 $arr['member_comment_info'] = $arro[0];
             } else {
                 $arr['member_comment_info'] = '';
                 $arr['member_comment'] = '0';
             }
         } else {
             $arr['merchant_comment'] = '0';
             $arr['member_comment'] = '0';
             $arr['merchant_comment_info'] = '';
             $arr['member_comment_info'] = '';
         }
         $sub_data = json_decode($arr['sub_data'], true);
         switch ($arr['type']) {
             // 0 預約 1需求 2活動
             case '0':
                 $arr['pics'] = imgUrl($sub_data['pics']);
                 $arr['distance'] = '';
                 $arr['list'] = $sub_data['list'];
                 break;
             case '1' or '3':
                 // 需求
                 $arr['pics'] = imgUrl($sub_data['pics']);
                 $arr['distance'] = $sub_data['distance'];
                 $arr['list'] = $sub_data['list'];
                 break;
             case '2':
                 // 活動
                 $arr['distance'] = '';
                 $arr['list'] = array();
                 break;
             default:
                 $this->jsonUtils->echo_json_msg(4, '數據異常');
                 exit;
                 break;
         }
         unset($arr['sub_data']);
         $this->jsonUtils->echo_json_data(0, 'ok', $arr);
     } else {
         $this->jsonUtils->echo_json_msg(1, '該訂單不存在...');
         exit;
     }
 }
開發者ID:sayi21cn,項目名稱:CarService-ServerSide,代碼行數:85,代碼來源:MerOrderController.class.php

示例12: EditSave

 /**
  *修改用戶
  */
 public function EditSave()
 {
     //獲取參數
     $id = I('id', 0, 'int');
     $username = I('username');
     $password = I('password');
     $email = I('email');
     $mobile = I('mobile');
     $roleid = I('role_id');
     //是否修改
     if ($id == 0) {
         $result['result'] = false;
         $result['msg'] = '該用戶不存在';
         $this->ajaxReturn($result);
     }
     //開啟事務
     $model = new Model();
     $model->startTrans();
     $flage === false;
     //申明修改用戶對象
     $data['UserName'] = $username;
     if (!empty($password)) {
         $data['PassWord'] = md5($password);
     }
     $data['Email'] = $email;
     $data['Mobile'] = $mobile;
     //更新
     $flage = $model->table('sys_user')->where('id=%d', $id)->save($data);
     if ($flage === false) {
         //事務回滾
         $model->rollback();
         $result['result'] = false;
         $result['msg'] = '修改用戶資料失敗!';
         $this->ajaxReturn($result);
     } else {
         $flage = $model->table('sys_role_user')->where('user_id=%d', $id)->delete();
         if ($flage === false) {
             //事務回滾
             $model->rollback();
             $result['result'] = false;
             $result['msg'] = '修改用戶資料失敗!';
             $this->ajaxReturn($result);
         }
         //角色處理
         foreach ($roleid as $key => $value) {
             # code...
             $data2['role_id'] = $value;
             $data2['user_id'] = $id;
             $flage = $model->table('sys_role_user')->add($data2);
             if ($flage === false) {
                 //事務回滾
                 $model->rollback();
                 $result['result'] = false;
                 $result['msg'] = '修改用戶資料失敗!';
                 $this->ajaxReturn($result);
             }
         }
         if ($flage) {
             //事務提交
             $model->commit();
             $result['result'] = true;
             $result['msg'] = '修改用戶資料成功!';
             $this->ajaxReturn($result);
         }
     }
 }
開發者ID:beyond1983,項目名稱:Blogs,代碼行數:69,代碼來源:SysuserController.class.php

示例13: testUnion

 public function testUnion()
 {
     $config = $this->getConfig();
     $user_model = new Model('user', $config);
     $union = "SELECT consignee FROM __USER_ADDRESS__";
     $result = $user_model->field('username')->union($union)->select();
     $this->assertEquals(4, count($result));
     $model = new Model('', $config);
     $union = ["SELECT create_time FROM __ORDER__"];
     $result = $model->table([$config['prefix'] . 'user'])->field('create_time')->union($union, true)->select();
     $this->assertEquals(4, count($result));
 }
開發者ID:cnzin,項目名稱:think,代碼行數:12,代碼來源:modelTest.php

示例14: getMerchantBiddingBy

 /**
  * 獲取商家對某個需求的各個項目報價
  */
 public function getMerchantBiddingBy($demand_id, $merchant_id, $publish)
 {
     $prefix = C('DB_PREFIX');
     if ($publish == 0) {
         $dbname = 'category';
     } elseif ($publish == 1) {
         $dbname = 'car_maintain_category';
     } else {
         $this->jsonUtils->echo_json_msg(4, 'publish方式出錯');
         exit;
     }
     $db = new Model();
     $data = $db->table($prefix . "member_demand_subitems as a")->field('b.name,b.id')->join($prefix . $dbname . ' as b on a.category_id = b.id')->where("a.demand_id = {$demand_id}")->select();
     $rel = M("MerchantBidding ")->field('sub_id as id,price,out_time as time')->where("demand_id = {$demand_id} and merchant_id\r\n    \t\t\t= {$merchant_id}")->select();
     foreach ($rel as $key => $row) {
         $price[$row['id']] = $row;
     }
     foreach ($data as $l => $r) {
         $data[$l]['price'] = !isset($price[$r['id']]['price']) ? '-1' : $price[$r['id']]['price'];
         $data[$l]['time'] = !isset($price[$r['id']]['time']) ? '-1' : $price[$r['id']]['time'];
     }
     return $data;
 }
開發者ID:sayi21cn,項目名稱:CarService-ServerSide,代碼行數:26,代碼來源:MemberDemandController.class.php

示例15: Del_Form_Data

 /**
  * 刪除數據
  * @param  string $datalist 數據集合
  */
 public function Del_Form_Data($vid, $mid)
 {
     $db_form = new DbformModel();
     $tables = $db_form->GetDBFormVid($vid);
     $Model = new Model();
     $tmd = $Model->table($tables['form_table']);
     $result = $tmd->where('id=' . $mid)->delete();
     return $result;
 }
開發者ID:GuiFox,項目名稱:Morplee,代碼行數:13,代碼來源:TableModel.class.php


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