Beispiel #1
0
 /**
  * update record
  *
  * @param App_Tag_Dm $dm
  * @return multitype:|Ambigous <boolean, number, rowCount>
  */
 public function update($id, App_Tag_Dm $dm)
 {
     if (true !== ($r = $dm->beforeUpdate())) {
         return $r;
     }
     return $this->loadDao()->update($id, $dm->getData());
 }
Beispiel #2
0
 public function editAction()
 {
     $tagId = $this->getInput('id', 'Request');
     $tagName = $this->getInput('name', 'Request');
     $tagType = $this->getInput('type', 'Request');
     if ($this->getInput('type', 'post') === 'do') {
         $tagName = $this->getInput('tagname', 'post');
         if (empty($tagName)) {
             $this->showError('请输入Tag名称');
             return;
         }
         $hasDuplicate = $this->_getTagDs()->checkDuplicateName($tagName);
         if ($hasDuplicate) {
             $this->showError('Tag:' . '"' . $tagName . '"' . '已存在');
             return;
         }
         $dm = new App_Tag_Dm();
         $dm->setTagName($tagName)->setLastUpdateTime(Pw::getTime());
         $this->_getTagDs()->update($tagId, $dm);
         $this->showMessage('更新成功');
     } else {
         $this->setOutput($tagId, 'tagId');
         $this->setOutput($tagName, 'tagName');
         $this->setOutput($tagType, 'tagType');
     }
 }
 public function run()
 {
     // $allTags=$this->_getTagDs()->getAllTags();
     // var_dump($allTags);
     $allMerchandises = $this->_getMerchandiseDs()->getAllMerchandises();
     // var_dump($allMerchandises);
     foreach ($allMerchandises as $item) {
         $tagidList[] = $item['tagid'];
     }
     // var_dump(count($tagidList));
     $tagidList = implode(',', $tagidList);
     // var_dump($tagidList);
     $tags = $this->_getTagDs()->getIncidentallyTags($tagidList);
     // var_dump($tags);
     $updateShopIdForTags = array();
     $index = 0;
     foreach ($tags as $tag) {
         foreach ($allMerchandises as $mer) {
             if ($tag['issystem'] == 0 && $tag['id'] == $mer['tagid']) {
                 $index++;
                 $updateShopIdForTags[$index]['tagid'] = $mer['tagid'];
                 $updateShopIdForTags[$index]['shopid'] = $mer['shopid'];
                 $updateShopIdForTags[$index]['name'] = $tag['name'];
             }
         }
     }
     echo "需要更新shopid的tag(" . count($updateShopIdForTags) . "):";
     echo "<pre>";
     var_export($updateShopIdForTags);
     //update
     $count = 0;
     foreach ($updateShopIdForTags as $item) {
         $count++;
         $dm = new App_Tag_Dm();
         $dm->setShopId($item['shopid'])->setLastUpdateTime(Pw::getTime());
         $this->_getTagDs()->update($item['tagid'], $dm);
     }
     echo "<pre>";
     echo "成功更新" . $count . "个tag";
 }
 private function updateShopTag()
 {
     $shopId = $this->getInput('shopid', 'get');
     $tags = $this->getInput('tags', 'post');
     $newTags = $this->getInput('newtags', 'post');
     if ($tags) {
         foreach ($tags as $key => $item) {
             $dm = new App_Tag_Dm();
             $dm->setShopId($shopId)->setTagName($item['name'])->setIsActive($item['isactive'])->setLastUpdateTime(Pw::getTime());
             $this->_getTagDs()->update($key, $dm);
         }
     }
     if ($newTags) {
         foreach ($newTags as $key => $item) {
             $tag['shopid'] = $shopId;
             $tag['name'] = $item['name'];
             $tag['isactive'] = $item['isactive'];
             $tag['issystem'] = 0;
             $tag['createdate'] = Pw::getTime();
             $tag['lastupdatetime'] = Pw::getTime();
             $dm = new App_Tag_Dm();
             $dm->setTag($tag);
             $this->_getTagDs()->add($dm);
         }
     }
     return true;
 }