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


PHP IModel::setData方法代码示例

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


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

示例1: add

 /**
  * 向词库中添加词
  * @param $word  string 多个词以','分隔
  * @param $hot   int    0:否;1:是
  * @param $order int    排序
  */
 public static function add($word, $hot = 0, $order = 99)
 {
     $word = IFilter::act($word);
     $hot = intval($hot);
     $order = intval($order);
     if ($word != '') {
         $keywordObj = new IModel('keyword');
         $wordArray = explode(',', $word);
         $wordArray = array_unique($wordArray);
         //获取各个关键词的管理商品数量
         $resultCount = self::count($wordArray);
         foreach ($wordArray as $word) {
             if (IString::getStrLen($word) >= 15) {
                 continue;
             }
             $is_exists = $keywordObj->getObj('word = "' . $word . '"', 'hot');
             if (empty($is_exists)) {
                 $dataArray = array('hot' => $hot, 'word' => $word, 'goods_nums' => $resultCount[$word], 'order' => $order);
                 $keywordObj->setData($dataArray);
                 $keywordObj->add();
             } else {
                 $dataArray = array('hot' => $hot, 'order' => $order);
                 $keywordObj->setData($dataArray);
                 $keywordObj->update("word = '" . $word . "'");
             }
         }
         return array('flag' => true);
     }
     return array('flag' => false, 'data' => '请填写关键词');
 }
开发者ID:herrify,项目名称:iwebshop,代码行数:36,代码来源:keywords.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: IModel

 /**
  * @brief 保存品牌
  */
 function brand_save()
 {
     $brand_id = IFilter::act(IReq::get('brand_id'), 'int');
     $name = IFilter::act(IReq::get('name'));
     $sort = IFilter::act(IReq::get('sort'), 'int');
     $url = IFilter::act(IReq::get('url'));
     $description = IFilter::act(IReq::get('description'), 'text');
     $tb_brand = new IModel('brand');
     $brand = array('name' => $name, 'sort' => $sort, 'url' => $url, 'description' => $description);
     if (isset($_FILES['logo']['name']) && $_FILES['logo']['name'] != '') {
         $uploadObj = new PhotoUpload();
         $uploadObj->setIterance(false);
         $photoInfo = $uploadObj->run();
         if (isset($photoInfo['logo']['img']) && file_exists($photoInfo['logo']['img'])) {
             $brand['logo'] = $photoInfo['logo']['img'];
         }
     }
     $tb_brand->setData($brand);
     if ($brand_id) {
         $where = "id=" . $brand_id;
         $tb_brand->update($where);
     } else {
         $tb_brand->add();
     }
     $this->brand_list();
 }
开发者ID:Wen1750686723,项目名称:utao,代码行数:29,代码来源:brand.php

示例4: _attribute_update

 /**
  * @brief 商品属性添加/修改
  * @param array $attribute 表字段 数组格式,如Array ([name] 		=> Array ( [0] => '' )
  *													[show_type] => Array ( [0] => '' )
  *													[value] 	=> Array ( [0] => '' )
  *													[is_seach] 	=> Array ( [0] => 1 ))
  * @param int $model_id 模型编号
  */
 public function _attribute_update($attribute, $model_id)
 {
     //初始化attribute商品模型属性表类对象
     $attributeObj = new IModel('attribute');
     $len = count($attribute['name']);
     $ids = "";
     for ($i = 0; $i < $len; $i++) {
         if (IValidate::required($attribute['name'][$i]) && IValidate::required($attribute['value'][$i])) {
             $options = str_replace(',', ',', $attribute['value'][$i]);
             $type = isset($attribute['is_search'][$i]) ? $attribute['is_search'][$i] : 0;
             //设置商品模型扩展属性 字段赋值
             $filedData = array("model_id" => intval($model_id), "type" => IFilter::act($attribute['show_type'][$i]), "name" => IFilter::act($attribute['name'][$i]), "value" => rtrim(IFilter::act($options), ','), "search" => IFilter::act($type));
             $attributeObj->setData($filedData);
             $id = intval($attribute['id'][$i]);
             if ($id) {
                 //更新商品模型扩展属性
                 $attributeObj->update("id = " . $id);
             } else {
                 //新增商品模型扩展属性
                 $id = $attributeObj->add();
             }
             $ids .= $id . ',';
         }
     }
     if ($ids) {
         $ids = trim($ids, ',');
         //删除商品模型扩展属性
         $where = "model_id = {$model_id}  and id not in (" . $ids . ") ";
         $attributeObj->del($where);
     }
 }
开发者ID:zhendeguoke1008,项目名称:shop,代码行数:39,代码来源:model.php

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

示例6: intval

 /**
  * @brief 回复建议
  */
 function suggestion_edit_act()
 {
     $id = intval(IReq::get('id', 'post'));
     $re_content = IFilter::act(IReq::get('re_content', 'post'), 'string');
     $tb = new IModel("suggestion");
     $data = array('admin_id' => $this->admin['admin_id'], 're_content' => $re_content, 're_time' => date('Y-m-d H:i:s'));
     $tb->setData($data);
     $tb->update("id={$id}");
     $this->redirect("/comment/suggestion_list");
 }
开发者ID:Wen1750686723,项目名称:utao,代码行数:13,代码来源:comment.php

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

示例8: intval

 /**
  * @brief 保存模板修改
  */
 function tpl_save()
 {
     $tid = intval(IReq::get('tpl_id', 'post'));
     if ($tid) {
         $title = IFilter::act(IReq::get('title'), 'string');
         $content = IFilter::act(IReq::get('content'), 'text');
         $tb_msg_template = new IModel('msg_template');
         $tb_msg_template->setData(array('title' => $title, 'content' => $content));
         $tb_msg_template->update('id=' . $tid);
     }
     $this->redirect('tpl_list');
 }
开发者ID:Wen1750686723,项目名称:utao,代码行数:15,代码来源:message.php

示例9: IModel

 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

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

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

示例12: write

 /**
  * 写入日志并且更新账户余额
  * @param array $config config数据类型
  * @return string|bool
  */
 public function write($config)
 {
     if (isset($config['user_id'])) {
         $this->setUser($config['user_id']);
     } else {
         throw new IException("用户信息不存在");
     }
     isset($config['seller_id']) ? $this->setSeller($config['seller_id']) : "";
     isset($config['admin_id']) ? $this->setAdmin($config['admin_id']) : "";
     isset($config['event']) ? $this->setEvent($config['event']) : "";
     if (isset($config['num']) && is_numeric($config['num'])) {
         $this->amount = abs(round($config['num'], 2));
         //金额正负值处理
         if (in_array($this->allow_event[$this->event], array(2, 3))) {
             $this->amount = '-' . abs($this->amount);
         }
     } else {
         throw new IException("金额必须大于0元");
     }
     $this->config = $config;
     $this->noteData = isset($config['note']) ? $config['note'] : $this->note();
     //写入数据库
     $finnalAmount = $this->user['balance'] + $this->amount;
     if ($finnalAmount < 0) {
         throw new IException("用户余额不足");
     }
     $memberDB = new IModel('member');
     $memberDB->setData(array("balance" => $finnalAmount));
     $memberDB->update("user_id = " . $this->user['id']);
     $tb_account_log = new IModel("account_log");
     $insertData = array('admin_id' => $this->admin ? $this->admin['id'] : 0, 'user_id' => $this->user['id'], 'event' => $this->allow_event[$this->event], 'note' => $this->noteData, 'amount' => $this->amount, 'amount_log' => $finnalAmount, 'type' => $this->amount >= 0 ? 0 : 1, 'time' => ITime::getDateTime());
     $tb_account_log->setData($insertData);
     $result = $tb_account_log->add();
     //后台管理员操作记录
     if ($insertData['admin_id']) {
         $logObj = new log('db');
         $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "对账户金额进行了修改", $insertData['note']));
     }
     return $result;
 }
开发者ID:herrify,项目名称:iwebshop,代码行数:45,代码来源:accountlog.php

示例13: SendMail

 /**
  * @brief 发送到货通知邮件
  */
 function notify_send()
 {
     $smtp = new SendMail();
     $error = $smtp->getError();
     if ($error) {
         $return = array('isError' => true, 'message' => $error);
         echo JSON::encode($return);
         exit;
     }
     $notify_ids = IFilter::act(IReq::get('notifyid'));
     $message = '';
     if ($notify_ids && is_array($notify_ids)) {
         $ids = join(',', $notify_ids);
         $query = new IQuery("notify_registry as notify");
         $query->join = "right join goods as goods on notify.goods_id=goods.id left join user as u on notify.user_id = u.id";
         $query->fields = "notify.*,u.username,goods.name as goods_name,goods.store_nums";
         $query->where = "notify.id in(" . $ids . ")";
         $items = $query->find();
         //库存大于0,且处于未发送状态的 发送通知
         $succeed = 0;
         $failed = 0;
         $tb_notify_registry = new IModel('notify_registry');
         foreach ($items as $value) {
             $body = mailTemplate::notify(array('{goodsName}' => $value['goods_name'], '{url}' => IUrl::getHost() . IUrl::creatUrl('/site/products/id/' . $value['goods_id'])));
             $status = $smtp->send($value['email'], "到货通知", $body);
             if ($status) {
                 //发送成功
                 $succeed++;
                 $data = array('notify_time' => ITime::getDateTime(), 'notify_status' => '1');
                 $tb_notify_registry->setData($data);
                 $tb_notify_registry->update('id=' . $value['id']);
             } else {
                 //发送失败
                 $failed++;
             }
         }
     }
     $return = array('isError' => false, 'count' => count($items), 'succeed' => $succeed, 'failed' => $failed);
     echo JSON::encode($return);
 }
开发者ID:yongge666,项目名称:sunupedu,代码行数:43,代码来源:message.php

示例14: upload

 function upload()
 {
     //图片上传
     $upObj = new IUpload();
     //目录散列
     $dir = IWeb::$app->config['upload'] . '/' . date('Y') . "/" . date('m') . "/" . date('d');
     $upObj->setDir($dir);
     $upState = $upObj->execute();
     //实例化
     $obj = new IModel('spec_photo');
     //检查上传状态
     foreach ($upState['attach'] as $val) {
         if ($val['flag'] == 1) {
             $insertData = array('address' => $val['dir'] . $val['name'], 'name' => $val['ininame'], 'create_time' => ITime::getDateTime());
             $obj->setData($insertData);
             $obj->add();
         }
     }
     if (count($upState['attach']) == 1) {
         return $upState['attach'][0];
     } else {
         return $upState['attach'];
     }
 }
开发者ID:chenyongze,项目名称:iwebshop,代码行数:24,代码来源:pic.php

示例15: IModel

 /**
  * @brief 品牌分类排序
  */
 function brand_sort()
 {
     $brand_id = IFilter::act(IReq::get('id'));
     $sort = IFilter::act(IReq::get('sort'));
     $flag = 0;
     if ($brand_id) {
         $tb_brand = new IModel('brand');
         $brand_info = $tb_brand->getObj('id=' . $brand_id);
         if (count($brand_info) > 0) {
             if ($brand_info['sort'] != $sort) {
                 $tb_brand->setData(array('sort' => $sort));
                 if ($tb_brand->update('id=' . $brand_id)) {
                     $flag = 1;
                 }
             }
         }
     }
     echo $flag;
 }
开发者ID:Wen1750686723,项目名称:utao,代码行数:22,代码来源:goods.php


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