public function add_dir($id) { //调用父类add方法 $result = parent::add(); //创建文件夹 mkdir('./Uploads/' . $id, 0777); return $result; }
/** * 添加地址 * @return bool|mixed */ public function add() { if (!empty($this->data['is_default'])) { $result = $this->where(array('member_id' => UID, 'status' => 1))->setField('is_default', 0); if ($result === false) { return false; } } return parent::add(); }
public function add($postData) { $this->startTrans(); //开启事物 //更新goods表 $this->dealStatus(); //处理status $id = parent::add(); if ($id === false) { $this->rollback(); //可以不用提醒,add会有提示 return false; } //生成sn $sn = date('Ymd') . str_pad($id, 9, 0, STR_PAD_LEFT); $rst = parent::save(array('id' => $id, 'sn' => $sn)); if ($rst === false) { $this->rollback(); $this->error = '保存货号失败!'; return false; } //将intro加入goods_intro表格 $model = M('GoodsIntro'); $result = $model->add(array('goods_id' => $id, 'intro' => $postData['intro'])); if ($result === false) { $this->rollback(); $this->error = '保存商品描述失败!'; return false; } //更新goods_member_price表 $result = $this->dealPrice($id, $postData); if ($result === false) { $this->rollback(); $this->error = '保存商品分类价格失败!'; return false; } //更新相册表 $result = $this->dealPhoto($id, $postData); if ($result === false) { $this->rollback(); $this->error = '保存商品相册失败!'; return false; } //更新相关文章表 $result = $this->dealArticle($id, $postData); if ($result === false) { $this->rollback(); $this->error = '保存商品文章失败!'; return false; } //提交事务 $this->commit(); return $id; }
function add($data, $compatible = false) { $res = parent::add($data, $compatible); if ($res === false) { return false; } $store_id = $data['store_id']; $userpriv_mod =& m('userpriv'); $userpriv_mod->add(array('store_id' => $store_id, 'user_id' => $store_id, 'privs' => 'all')); return $res; }
/** * 重写父类的add方法 * @param mixed|string $postData * @return mixed */ public function add($postData) { //dump($postData);exit; $this->startTrans(); //1> 添加到goods表中 //处理商品状态 $this->handleStatus(); //添加商品上架时间 $this->data['inputtime'] = time(); $id = parent::add(); if ($id === false) { $this->rollback(); return false; } //2>生成商品货号,更新商品表 $sn = date('Ymd') . str_pad($id, 9, '0', STR_PAD_LEFT); $result = parent::save(array('id' => $id, 'sn' => $sn)); if ($result === false) { $this->rollback(); return false; } //3>处理商品的会员价格 $result = $this->handleMemberPrice($id, $postData['memberPrices']); if ($result === false) { return false; } //4>处理商品描述 $result = $this->handleIntro($id, $postData['intro']); if ($result === false) { return fasle; } //>5处理商品相册 if (isset($postData['goods_gallerys'])) { $result = $this->handleGallery($id, $postData['goods_gallerys']); if ($result === false) { return fasle; } } //>5处理相关文章 if (isset($postData['article_ids'])) { $result = $this->handleArticle($id, $postData['article_ids']); if ($result === false) { return fasle; } } //6>处理商品属性 $result = $this->handleAttribute($id, $postData['attribute']); if ($result === false) { return fasle; } $this->commit(); return $id; }
/** * 重写add方法,添加角色权限信息 * @param mixed|string $requestData * @return bool|mixed */ public function add($requestData) { //添加角色信息 $id = parent::add(); if ($id === false) { return false; } //添加角色权限信息 $rst = $this->handleRolePermission($id, $requestData['permission_ids']); if ($rst === false) { return false; } return $id; }
/** * 重写父类的add方法 * @param mixed|string $postData * @return bool */ public function add($postData) { //保存文章信息 $id = parent::add(); if ($id === false) { return fasle; } //保存文章内容 $articleContent = M('ArticleContent'); $rst = $articleContent->add(array('article_id' => $id, 'content' => $postData['content'])); if ($rst === false) { $this->error = '添加文章内容失败'; return false; } return $id; }
/** * 重写add方法,添加管理员角色表信息以及额外权限信息 * @param mixed|string $requestData * @return bool|mixed */ public function add($requestData) { //添加管理员信息 //处理密码 $this->data['password'] = myMd5($this->data['password'], $this->data['salt']); $id = parent::add(); if ($id === false) { return false; } //处理管理员角色表 $rst = $this->handleAdminRole($id, $requestData['role_ids']); if ($rst === false) { return false; } //处理管理员额外权限表 $rst = $this->handleExtraPermission($id, $requestData['permission_ids']); if ($rst === false) { return false; } return $id; }
public function add($postData) { $this->startTrans(); //开启事务 //更新article表 $id = parent::add(); if ($id === false) { $this->rollback(); //可以不用提醒,add会有提示 return false; } //更新atricle_content表 $model = M('ArticleContent'); $result = $model->add(array('article_id' => $id, 'content' => $postData['article_content'])); if ($result === false) { $this->rollback(); $this->error = '保存文章内容失败!'; return false; } //提交事务 $this->commit(); return $result; }
function add($data, $compatible = false) { $this->clear_cache(); return parent::add($data, $compatible); }