本文整理汇总了PHP中IModel::add方法的典型用法代码示例。如果您正苦于以下问题:PHP IModel::add方法的具体用法?PHP IModel::add怎么用?PHP IModel::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IModel
的用法示例。
在下文中一共展示了IModel::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: add
public static function add($word, $hot, $order = 99)
{
$word = IFilter::act($word);
$hot = intval($hot);
$order = intval($order);
if ($word != '') {
$keywordObj = new IModel('keyword');
$wordArray = explode(',', $word);
//获取各个关键词的管理商品数量
$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();
}
}
return array('flag' => true);
}
return array('flag' => false, 'data' => '请填写关键词');
}
示例3: writeLog
/**
* @brief 日志记录
* @param array $config => array('user_id' => 用户ID , 'point' => 积分增减(正,负区分) , 'log' => 日志记录内容)
*/
private function writeLog($config)
{
//修改pointLog表
$poinLogObj = new IModel('point_log');
$pointLogArray = array('user_id' => $config['user_id'], 'datetime' => ITime::getDateTime(), 'value' => $config['point'], 'intro' => $config['log']);
$poinLogObj->setData($pointLogArray);
return $poinLogObj->add();
}
示例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;
}
}
}
示例5: complain_edit
/**
* @brief 建议中心
*/
public function complain_edit()
{
$id = IFilter::act(IReq::get('id'), 'int');
$title = IFilter::act(IReq::get('title'), 'string');
$content = IFilter::act(IReq::get('content'), 'string');
$user_id = $this->user['user_id'];
$model = new IModel('suggestion');
$model->setData(array('user_id' => $user_id, 'title' => $title, 'content' => $content, 'time' => date('Y-m-d H:i:s')));
if ($id == '') {
$model->add();
} else {
$model->update('id = ' . $id);
}
$this->redirect('complain');
}
示例6: 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;
}
}
示例7: 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();
}
}
}
示例8: 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;
}
示例9: 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'];
}
}
示例10: sendToUser
/**
* 直接发站内信到用户
* 这个地方直接调用了Mysql的操作类
* @param $userIds string 用户Id的串
* @param $content 信件内容 array('title' => '标题','content' => '内容')
*/
public static function sendToUser($userIds, $content)
{
set_time_limit(0);
//插入$content
$data = array('title' => IFilter::act($content['title']), 'content' => IFilter::act($content['content'], 'text'), 'time' => date('Y-m-d H:i:s'));
$msgDB = new IModel("message");
$msgDB->setData($data);
$id = $msgDB->add();
if ($id === false) {
return false;
} else {
$db = IDBFactory::getDB();
$tableName = IWeb::$app->config['DB']['tablePre'] . "member";
if ($userIds) {
$sql = "UPDATE `{$tableName}` SET message_ids = CONCAT( IFNULL(message_ids,'') ,'{$id},') WHERE user_id in ({$userIds})";
} else {
$sql = "UPDATE `{$tableName}` SET message_ids = CONCAT( IFNULL(message_ids,'') ,'{$id},')";
}
return $db->query($sql);
}
}
示例11: IModel
/**
* @brief 保存商品分类
*/
function category_save()
{
//获得post值
$category_id = IFilter::act(IReq::get('category_id'), 'int');
$name = IFilter::act(IReq::get('name'));
$parent_id = IFilter::act(IReq::get('parent_id'), 'int');
$visibility = IFilter::act(IReq::get('visibility'), 'int');
$sort = IFilter::act(IReq::get('sort'), 'int');
$title = IFilter::act(IReq::get('title'));
$keywords = IFilter::act(IReq::get('keywords'));
$descript = IFilter::act(IReq::get('descript'));
$tb_category = new IModel('category');
$category_info = array('name' => $name, 'parent_id' => $parent_id, 'sort' => $sort, 'visibility' => $visibility, 'keywords' => $keywords, 'descript' => $descript, 'title' => $title);
$tb_category->setData($category_info);
if ($category_id) {
$where = "id=" . $category_id;
$tb_category->update($where);
} else {
$tb_category->add();
}
//更新缓存
$cacheObj = new ICache('file');
$cacheObj->del('goodsCategory');
$this->category_list();
}
示例12: foreach
function spec_update()
{
//获取是否为block模块
$isBlock = IReq::get('block', 'get');
//显示方式
$specType = IReq::get('type', 'post');
//规格数据
$valueArray = IReq::get('value', 'post');
//要插入的数据
if (is_array($valueArray) && isset($valueArray[0]) && $valueArray[0] != '') {
$valueArray = array_unique($valueArray);
foreach ($valueArray as $key => $rs) {
if ($rs == '') {
unset($valueArray[$key]);
}
}
if (!$valueArray) {
$isPass = false;
$errorMessage = "请上传规格图片";
} else {
$value = serialize($valueArray);
}
} else {
$value = '';
}
$editData = array('id' => IReq::get('id', 'post'), 'name' => IReq::get('name', 'post'), 'value' => $value, 'type' => IReq::get('type', 'post'), 'note' => IReq::get('note', 'post'));
//校验
$isPass = true;
if ($value == '') {
$isPass = false;
$errorMessage = '规格值不能为空,请填写规格值或上传规格图片';
}
if ($editData['name'] == '') {
$isPass = false;
$errorMessage = '规格名称不能为空';
}
if ($isPass == false) {
//block部分
if ($isBlock !== null) {
$blockObj = new Block($this->module, 'block');
$blockObj->setRenderData($editData);
$blockObj->redirect('spec_edit', false);
} else {
$this->setRenderData($editData);
$this->redirect('spec_edit', false);
}
Util::showMessage($errorMessage);
} else {
$obj = new IModel('spec');
//执行操作
$obj->setData($editData);
if ($id = IReq::get('id')) {
$where = 'id = ' . $id;
$result = $obj->update($where);
} else {
$result = $obj->add();
}
//执行状态
if ($result === false) {
//block部分
if ($isBlock !== null) {
$blockObj = new Block($this->module, 'block');
$blockObj->setRenderData($editData);
$blockObj->redirect('spec_edit', false);
} else {
$this->setRenderData($editData);
$this->redirect('spec_edit');
}
} else {
//block部分
if ($isBlock !== null) {
echo '<script>parent.closeSpec();</script>';
} else {
$this->redirect('spec_list');
}
}
}
}
示例13: explode
function goods_copy()
{
$idArray = explode(',', IReq::get('id'));
$idArray = IFilter::act($idArray, 'int');
$goodsDB = new IModel('goods');
$goodsAttrDB = new IModel('goods_attribute');
$goodsPhotoRelationDB = new IModel('goods_photo_relation');
$productsDB = new IModel('products');
$goodsData = $goodsDB->query('id in (' . join(',', $idArray) . ') and is_share = 1 and is_del = 0 and seller_id = 0', '*');
if ($goodsData) {
foreach ($goodsData as $key => $val) {
//判断是否重复
if ($goodsDB->getObj('seller_id = ' . $this->seller['seller_id'] . ' and name = "' . $val['name'] . '"')) {
die('商品不能重复复制');
}
$oldId = $val['id'];
//商品数据
unset($val['id'], $val['visit'], $val['favorite'], $val['sort'], $val['comments'], $val['sale'], $val['grade'], $val['is_share']);
$val['seller_id'] = $this->seller['seller_id'];
$val['goods_no'] .= '-' . $this->seller['seller_id'];
$goodsDB->setData($val);
$goods_id = $goodsDB->add();
//商品属性
$attrData = $goodsAttrDB->query('goods_id = ' . $oldId);
if ($attrData) {
foreach ($attrData as $k => $v) {
unset($v['id']);
$v['goods_id'] = $goods_id;
$goodsAttrDB->setData($v);
$goodsAttrDB->add();
}
}
//商品图片
$photoData = $goodsPhotoRelationDB->query('goods_id = ' . $oldId);
if ($photoData) {
foreach ($photoData as $k => $v) {
unset($v['id']);
$v['goods_id'] = $goods_id;
$goodsPhotoRelationDB->setData($v);
$goodsPhotoRelationDB->add();
}
}
//货品
$productsData = $productsDB->query('goods_id = ' . $oldId);
if ($productsData) {
foreach ($productsData as $k => $v) {
unset($v['id']);
$v['products_no'] .= '-' . $this->seller['seller_id'];
$v['goods_id'] = $goods_id;
$productsDB->setData($v);
$productsDB->add();
}
}
}
die('success');
} else {
die('复制的商品不存在');
}
}
示例14: cat_edit
public static function cat_edit($arr)
{
if (!isset($arr['id']) || $arr['id'] === null || !preg_match("![0-9]+!", $arr['id'])) {
unset($arr['id']);
}
if ($arr['name'] === null || !preg_match('!^.{1,10}$!u', $arr['name'])) {
return array('flag' => false, 'data' => '分类名称不能超过十个文字');
}
$arr['name'] = htmlspecialchars($arr['name'], ENT_QUOTES);
$arr['sort'] = intval($arr['sort']);
$arr['position_left'] = intval($arr['position_left']) == 1 ? 1 : 0;
$arr['position_foot'] = intval($arr['position_foot']) == 1 ? 1 : 0;
$tb_help_category = new IModel("help_category");
$tb_help_category->setData($arr);
if (isset($arr['id'])) {
$id = intval($arr['id']);
unset($arr['id']);
$tb_help_category->update("id={$id}");
} else {
$tb_help_category->add($arr);
}
return array('flag' => true, 'data' => "编辑成功");
}
示例15: IModel
function navigation_update()
{
$id = IFilter::act(IReq::get('id', 'post'), 'int');
$navigationObj = new IModel('quick_naviga');
$navigationObj->setData(array('adminid' => $this->admin['admin_id'], 'naviga_name' => IFilter::act(IReq::get('naviga_name')), 'url' => IFilter::act(IReq::get('url'))));
if ($id) {
$navigationObj->update('id=' . $id);
} else {
$navigationObj->add();
}
$this->redirect('navigation');
}