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


PHP IModel类代码示例

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


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

示例1: editPoint

 /**
  * @brief 积分更新
  * @param int $user_id 用户ID
  * @param int $point   积分数(正,负)
  */
 private function editPoint($user_id, $point)
 {
     $memberObj = new IModel('member');
     $memberArray = array('point' => 'point + ' . $point);
     $memberObj->setData($memberArray);
     return $memberObj->update('user_id = ' . $user_id, 'point');
 }
开发者ID:Wen1750686723,项目名称:utao,代码行数:12,代码来源:point.php

示例2: login

 /**
  * @brief 商家登录动作
  */
 public function login()
 {
     $seller_name = IFilter::act(IReq::get('username'));
     $password = IReq::get('password');
     $message = '';
     if ($seller_name == '') {
         $message = '登录名不能为空';
     } else {
         if ($password == '') {
             $message = '密码不能为空';
         } else {
             $sellerObj = new IModel('seller');
             $sellerRow = $sellerObj->getObj('seller_name = "' . $seller_name . '" and is_del = 0 and is_lock = 0');
             if ($sellerRow && $sellerRow['password'] == md5($password)) {
                 $dataArray = array('login_time' => ITime::getDateTime());
                 $sellerObj->setData($dataArray);
                 $where = 'id = ' . $sellerRow["id"];
                 $sellerObj->update($where);
                 //存入私密数据
                 ISafe::set('seller_id', $sellerRow['id']);
                 ISafe::set('seller_name', $sellerRow['seller_name']);
                 ISafe::set('seller_pwd', $sellerRow['password']);
                 $this->redirect('/seller/index');
             } else {
                 $message = '用户名与密码不匹配';
             }
         }
     }
     if ($message != '') {
         $this->redirect('index', false);
         Util::showMessage($message);
     }
 }
开发者ID:yongge666,项目名称:sunupedu,代码行数:36,代码来源:systemseller.php

示例3: getDelivery

 /**
  * @param $province string 省份的id
  * @param $weight int 货物的重量
  * @param $goodsSum float 商品总价格
  * @return array()
  * @brief 配送方式计算管理模块
  */
 public static function getDelivery($province, $weight = 0, $goodsSum = 0)
 {
     $data = array();
     //获得配送方式表的对象
     $delivery = new IModel('delivery');
     //获取配送方式列表
     $where = 'is_delete = 0 and status = 1';
     $list = $delivery->query($where, '*', 'sort', 'asc');
     //循环各个配送方式
     foreach ($list as $value) {
         //设置首重和次重
         self::$firstWeight = $value['first_weight'];
         self::$secondWeight = $value['second_weight'];
         $data[$value['id']]['id'] = $value['id'];
         $data[$value['id']]['name'] = $value['name'];
         $data[$value['id']]['type'] = $value['type'];
         $data[$value['id']]['description'] = $value['description'];
         $data[$value['id']]['if_delivery'] = '0';
         //当配送方式是统一配置的时候,不进行区分地区价格
         if ($value['price_type'] == 0) {
             $data[$value['id']]['price'] = self::getFeeByWeight($weight, $value['first_price'], $value['second_price']);
         } else {
             $matchKey = '';
             $flag = false;
             //每项都是以';'隔开的省份ID
             $area_groupid = unserialize($value['area_groupid']);
             foreach ($area_groupid as $key => $result) {
                 //匹配到了特殊的省份运费价格
                 if (strpos($result, ';' . $province . ';') !== false) {
                     $matchKey = $key;
                     $flag = true;
                     break;
                 }
             }
             //匹配到了特殊的省份运费价格
             if ($flag) {
                 //获取当前省份特殊的运费价格
                 $firstprice = unserialize($value['firstprice']);
                 $secondprice = unserialize($value['secondprice']);
                 $data[$value['id']]['price'] = self::getFeeByWeight($weight, $firstprice[$matchKey], $secondprice[$matchKey]);
             } else {
                 //判断是否设置默认费用了
                 if ($value['open_default'] == 1) {
                     $data[$value['id']]['price'] = self::getFeeByWeight($weight, $value['first_price'], $value['second_price']);
                 } else {
                     $data[$value['id']]['price'] = '0';
                     $data[$value['id']]['if_delivery'] = '1';
                 }
             }
         }
         //计算保价
         if ($value['is_save_price'] == 1) {
             $tempProtectPrice = $goodsSum * ($value['save_rate'] * 0.01);
             $data[$value['id']]['protect_price'] = $tempProtectPrice <= $value['low_price'] ? $value['low_price'] : $tempProtectPrice;
         } else {
             $data[$value['id']]['protect_price'] = 0;
         }
     }
     return $data;
 }
开发者ID:yongge666,项目名称:sunupedu,代码行数:67,代码来源:delivery.php

示例4: curd

 /**
  * @brief 处理curd动作
  * @return String
  */
 public function curd()
 {
     $action = $this->id;
     $controller = $this->controller;
     $curdinfo = $this->initinfo();
     if (is_array($curdinfo)) {
         $modelName = $curdinfo['model'];
         $key = $curdinfo['key'];
         $actions = $curdinfo['actions'];
         switch ($action) {
             case 'add':
             case 'upd':
                 if (method_exists($controller, 'getValidate')) {
                     $validate = $controller->getValidate();
                 } else {
                     $validate = null;
                 }
                 if ($validate != null) {
                     $formValidate = new IFormValidation($validate);
                     $data = $formValidate->run();
                 }
                 $model = new IModel($modelName);
                 if (isset($data) && $data !== null) {
                     $model->setData($data[$modelName]);
                     if ($action = 'add') {
                         $flag = $model->add();
                     } else {
                         $flag = $model->upd("{$key} = '" . IReq::get($key) . "'");
                     }
                 }
                 if (isset($flag) && $flag) {
                     $_GET['action'] = $actions['success'];
                 } else {
                     $_GET['action'] = $actions['fail'];
                 }
                 $controller->run();
                 return true;
             case 'del':
                 $model = new IModel($modelName);
                 $flag = $model->del("{$key} = '" . IReq::get($key) . "'");
                 if ($flag) {
                     $_GET['action'] = $actions['success'];
                 } else {
                     $_GET['action'] = $actions['fail'];
                 }
                 $controller->run();
                 return true;
             case 'get':
                 $model = new IModel($modelName);
                 $rs = $model->getObj("{$key} = '" . IReq::get($key) . "'");
                 echo JSON::encode($rs);
                 return false;
         }
     }
 }
开发者ID:chenyongze,项目名称:iwebshop,代码行数:59,代码来源:curd_action.php

示例5: name

 /**
  * @brief 根据传入的地域ID获取地域名称,获取的名称是根据ID依次获取的
  * @param int 地域ID 匿名参数可以多个id
  * @return array
  */
 public static function name()
 {
     $result = array();
     $paramArray = func_get_args();
     $areaDB = new IModel('areas');
     $areaData = $areaDB->query("area_id in (" . trim(join(',', $paramArray), ",") . ")");
     foreach ($areaData as $key => $value) {
         $result[$value['area_id']] = $value['area_name'];
     }
     return $result;
 }
开发者ID:yongge666,项目名称:sunupedu,代码行数:16,代码来源:area.php

示例6: getAuth

 public static function getAuth(IModel $player, $password)
 {
     if ($player->exists()) {
         if (password_verify(trim($password), $player->getPlayer()['password'])) {
             $_SESSION['id'] = $player->getPlayer()['id'];
             $_SESSION['name'] = $player->getPlayer()['name'];
             $_SESSION['auth'] = 1;
             return true;
         }
         return false;
     }
     return false;
 }
开发者ID:Ate1st,项目名称:test,代码行数:13,代码来源:auth.php

示例7: login_act

 function login_act()
 {
     $admin_name = IFilter::act(IReq::get('admin_name'));
     $password = IReq::get('password');
     $captcha = IReq::get('captcha', 'post');
     $message = '';
     if ($admin_name == '') {
         $message = '登录名不能为空';
     } else {
         if ($password == '') {
             $message = '密码不能为空';
         } else {
             if ($captcha != ISafe::get('Captcha')) {
                 $message = '验证码输入不正确';
             } else {
                 $adminObj = new IModel('admin');
                 $adminRow = $adminObj->getObj('admin_name = "' . $admin_name . '"');
                 if (!empty($adminRow) && $adminRow['password'] == md5($password) && $adminRow['is_del'] == 0) {
                     $dataArray = array('last_ip' => IClient::getIp(), 'last_time' => ITime::getDateTime());
                     $adminObj->setData($dataArray);
                     $where = 'id = ' . $adminRow["id"];
                     $adminObj->update($where);
                     //根据角色分配权限
                     if ($adminRow['role_id'] == 0) {
                         ISafe::set('admin_right', 'administrator');
                         ISafe::set('admin_role_name', '超级管理员');
                     } else {
                         $roleObj = new IModel('admin_role');
                         $where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0';
                         $roleRow = $roleObj->getObj($where);
                         ISafe::set('admin_right', $roleRow['rights']);
                         ISafe::set('admin_role_name', $roleRow['name']);
                     }
                     ISafe::set('admin_id', $adminRow['id']);
                     ISafe::set('admin_name', $adminRow['admin_name']);
                     ISafe::set('admin_pwd', $adminRow['password']);
                     $this->redirect('/system/default');
                 } else {
                     $message = '用户名与密码不匹配';
                 }
             }
         }
     }
     if ($message != '') {
         $this->admin_name = $admin_name;
         $this->redirect('index', false);
         Util::showMessage($message);
     }
 }
开发者ID:chenyongze,项目名称:iwebshop,代码行数:49,代码来源:systemadmin.php

示例8: __construct

 /**
  * @brief 构造函数
  * @param array checkrights里面的admin对象数据
  */
 public function __construct($admin)
 {
     $adminObj = new IModel('admin');
     $adminRow = $adminObj->getObj('admin_name = "' . $admin['admin_name'] . '"');
     if ($adminRow && $adminRow['password'] == $admin['admin_pwd'] && $adminRow['is_del'] == 0) {
         //根据角色分配权限
         if ($adminRow['role_id'] == 0) {
             $this->adminRights = 'administrator';
         } else {
             $roleObj = new IModel('admin_role');
             $where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0';
             $roleRow = $roleObj->getObj($where);
             $this->adminRights = isset($roleRow['rights']) ? $roleRow['rights'] : '';
         }
     }
 }
开发者ID:herrify,项目名称:iwebshop,代码行数:20,代码来源:menu.php

示例9: write

 /**
  * @brief 向数据库写入log
  * @param array  log数据
  * @return bool  操作结果
  */
 public function write($logs = array())
 {
     if (!is_array($logs) || empty($logs)) {
         throw new IException('the $logs parms must be array');
     }
     if ($this->tableName == '') {
         throw new IException('the tableName is undefined');
     }
     $logObj = new IModel($this->tableName);
     $logObj->setData($logs);
     $result = $logObj->add();
     if ($result) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:chenyongze,项目名称:iwebshop,代码行数:22,代码来源:dblog_class.php

示例10: isValidUser

 /**
  * @brief  校验用户的合法性
  * @param  string $login_info 用户名或者email
  * @param  string $password   用户名的md5密码
  * @return false or array 如果合法则返回用户数据;不合法返回false
  */
 public static function isValidUser($login_info, $password)
 {
     $login_info = IFilter::act($login_info);
     $password = IFilter::act($password);
     $userObj = new IModel('user as u,member as m');
     $where = 'u.username = "' . $login_info . '" and m.status = 1 and u.id = m.user_id';
     $userRow = $userObj->getObj($where);
     if (empty($userRow)) {
         $where = 'email = "' . $login_info . '" and m.status = 1 and u.id = m.user_id';
         $userRow = $userObj->getObj($where);
     }
     if (empty($userRow) || $userRow['password'] != $password) {
         return false;
     } else {
         return $userRow;
     }
 }
开发者ID:zhendeguoke1008,项目名称:shop,代码行数:23,代码来源:checkrights.php

示例11: unsubscribe

 /**
  * 退订,并记录退订理由
  * @param string $email 
  * @param string $content 退订理由
  * @static
  */
 public static function unsubscribe($email, $content)
 {
     $email = addslashes($email);
     $tb = new IModel("email_registry");
     $re = $tb->query("email = '{$email}' AND flag=1");
     if (!$re) {
         return array('flag' => false, 'data' => '你还没有订阅');
     }
     $re = end($re);
     /*
     $re['content'] = htmlspecialchars($content,ENT_QUOTES);
     $re['flag'] = 0;
     $tb->setData($re);
     $tb->update("id={$re['id']}");
     */
     $tb->del("id={$re['id']}");
     return array('flag' => true, 'data' => 'success');
 }
开发者ID:Wen1750686723,项目名称:utao,代码行数:24,代码来源:subscribe.php

示例12: showCat

 static function showCat($selectName = 'category_id', $selectedValue = null, $defaultValue = array())
 {
     //取得文章分类信息
     $catObj = new IModel('article_category');
     $data = $catObj->query('', 'id,name,path', 'path', 'asc');
     $str = '<select class="auto" name="' . $selectName . '" pattern="required" alt="请选择分类值">';
     //默认option值
     if (!empty($defaultValue)) {
         $str .= '<option value="' . current($defaultValue) . '">' . key($defaultValue) . '</option>';
     }
     //拼接分类信息
     foreach ($data as $val) {
         $isSelect = $val['id'] == $selectedValue ? 'selected=selected' : null;
         $str .= '<option value="' . $val['id'] . '" ' . $isSelect . '>' . str_repeat("&nbsp;&nbsp;", substr_count($val['path'], ",") - 2) . '└' . $val['name'] . '</option>';
     }
     $str .= '</select>';
     return $str;
 }
开发者ID:Wen1750686723,项目名称:utao,代码行数:18,代码来源:article.php

示例13: can_comment

 /**
  * 检测用户是否能够评论
  *
  * @param int $comment_id 评论id
  * @param int $user_id 用户id
  * @return array() array(成功or失败,数据)
  */
 public static function can_comment($comment_id, $user_id)
 {
     $comment_id = intval($comment_id);
     $user_id = intval($user_id);
     $tb_comment = new IModel("comment");
     $comment = $tb_comment->getObj("id={$comment_id} AND user_id={$user_id}");
     if (!$comment) {
         return array(-1, "没有这条数据");
     }
     if ($comment['status'] != 0) {
         return array(-2, $comment);
     }
     $time = strtotime($comment['time']);
     if ($time < 3600 * 24 * 30 * 6) {
         return array(-3, $comment);
     }
     return array(1, $comment);
 }
开发者ID:zhendeguoke1008,项目名称:shop,代码行数:25,代码来源:comment_class.php

示例14: ucenter_order

 public static function ucenter_order()
 {
     $siteConfig = new Config('site_config');
     $order_cancel_time = $siteConfig->order_cancel_time !== "" ? intval($siteConfig->order_cancel_time) : 7;
     $order_finish_time = $siteConfig->order_finish_time !== "" ? intval($siteConfig->order_finish_time) : 20;
     $orderModel = new IModel('order');
     $orderCancelData = $order_cancel_time >= 0 ? $orderModel->query(" if_del = 0 and pay_type != 0 and status in(1) and datediff(NOW(),create_time) >= {$order_cancel_time} ", "id,order_no,4 as type_data") : array();
     $orderCreateData = $order_finish_time >= 0 ? $orderModel->query(" if_del = 0 and distribution_status = 1 and status in(1,2) and datediff(NOW(),send_time) >= {$order_finish_time} ", "id,order_no,5 as type_data") : array();
     $resultData = array_merge($orderCreateData, $orderCancelData);
     if ($resultData) {
         foreach ($resultData as $key => $val) {
             $type = $val['type_data'];
             $order_id = $val['id'];
             $order_no = $val['order_no'];
             //oerder表的对象
             $tb_order = new IModel('order');
             $tb_order->setData(array('status' => $type, 'completion_time' => ITime::getDateTime()));
             $tb_order->update('id=' . $order_id);
             //生成订单日志
             $tb_order_log = new IModel('order_log');
             //订单自动完成
             if ($type == '5') {
                 $action = '完成';
                 $note = '订单【' . $order_no . '】完成成功';
                 //完成订单并且进行支付
                 Order_Class::updateOrderStatus($order_no);
                 //增加用户评论商品机会
                 Order_Class::addGoodsCommentChange($order_id);
                 $logObj = new log('db');
                 $logObj->write('operation', array("系统自动", "订单更新为完成", '订单号:' . $order_no));
             } else {
                 $action = '作废';
                 $note = '订单【' . $order_no . '】作废成功';
                 //订单重置取消
                 Order_class::resetOrderProp($order_id);
                 $logObj = new log('db');
                 $logObj->write('operation', array("系统自动", "订单更新为作废", '订单号:' . $order_no));
             }
             $tb_order_log->setData(array('order_id' => $order_id, 'user' => "系统自动", 'action' => $action, 'result' => '成功', 'note' => $note, 'addtime' => ITime::getDateTime()));
             $tb_order_log->add();
         }
     }
 }
开发者ID:herrify,项目名称:iwebshop,代码行数:43,代码来源:hookCreateAction.php

示例15: brand_del

 /**
  * @brief 删除品牌
  */
 function brand_del()
 {
     $brand_id = (int) IReq::get('bid');
     if ($brand_id) {
         $tb_brand = new IModel('brand');
         $where = "id=" . $brand_id;
         if ($tb_brand->del($where)) {
             $this->brand_list();
         } else {
             $this->brand_list();
             $msg = "没有找到相关分类记录!";
             Util::showMessage($msg);
         }
     } else {
         $this->brand_list();
         $msg = "没有找到相关品牌记录!";
         Util::showMessage($msg);
     }
 }
开发者ID:Wen1750686723,项目名称:utao,代码行数:22,代码来源:brand.php


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