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


PHP AdapterInterface::update方法代码示例

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


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

示例1: move

 /**
  * Move tree node
  *
  * @param Node $node
  * @param Node $newParent
  * @param Node $prevNode
  * @return void
  * @throws \Exception
  * @todo Use adapter for generate conditions
  */
 public function move($node, $newParent, $prevNode = null)
 {
     $position = 1;
     $oldPath = $node->getData($this->_pathField);
     $newPath = $newParent->getData($this->_pathField);
     $newPath = $newPath . '/' . $node->getId();
     $oldPathLength = strlen($oldPath);
     $newLevel = $newParent->getLevel() + 1;
     $levelDisposition = $newLevel - $node->getLevel();
     $data = [$this->_levelField => new \Zend_Db_Expr("{$this->_levelField} + '{$levelDisposition}'"), $this->_pathField => new \Zend_Db_Expr("CONCAT('{$newPath}', RIGHT({$this->_pathField}, LENGTH({$this->_pathField}) - {$oldPathLength}))")];
     $condition = $this->_conn->quoteInto("{$this->_pathField} REGEXP ?", "^{$oldPath}(/|\$)");
     $this->_conn->beginTransaction();
     $reorderData = [$this->_orderField => new \Zend_Db_Expr("{$this->_orderField} + 1")];
     try {
         if ($prevNode && $prevNode->getId()) {
             $reorderCondition = "{$this->_orderField} > {$prevNode->getData($this->_orderField)}";
             $position = $prevNode->getData($this->_orderField) + 1;
         } else {
             $reorderCondition = $this->_conn->quoteInto("{$this->_pathField} REGEXP ?", "^{$newParent->getData($this->_pathField)}/[0-9]+\$");
             $select = $this->_conn->select()->from($this->_table, new \Zend_Db_Expr("MIN({$this->_orderField})"))->where($reorderCondition);
             $position = (int) $this->_conn->fetchOne($select);
         }
         $this->_conn->update($this->_table, $reorderData, $reorderCondition);
         $this->_conn->update($this->_table, $data, $condition);
         $this->_conn->update($this->_table, [$this->_orderField => $position, $this->_levelField => $newLevel], $this->_conn->quoteInto("{$this->_idField} = ?", $node->getId()));
         $this->_conn->commit();
     } catch (\Exception $e) {
         $this->_conn->rollBack();
         throw new \Exception("Can't move tree node due to error: " . $e->getMessage());
     }
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:41,代码来源:Dbp.php

示例2: received

 /**
  * Updates data when subscriber received
  *
  * @param \Magento\Newsletter\Model\Subscriber $subscriber
  * @param \Magento\Newsletter\Model\Queue $queue
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function received(\Magento\Newsletter\Model\Subscriber $subscriber, \Magento\Newsletter\Model\Queue $queue)
 {
     $this->connection->beginTransaction();
     try {
         $data['letter_sent_at'] = $this->_date->gmtDate();
         $this->connection->update($this->_subscriberLinkTable, $data, ['subscriber_id = ?' => $subscriber->getId(), 'queue_id = ?' => $queue->getId()]);
         $this->connection->commit();
     } catch (\Exception $e) {
         $this->connection->rollBack();
         throw new \Magento\Framework\Exception\LocalizedException(__('We cannot mark as received subscriber.'));
     }
     return $this;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:21,代码来源:Subscriber.php

示例3: write

 /**
  * Update session
  *
  * @param string $sessionId
  * @param string $sessionData
  * @return bool
  */
 public function write($sessionId, $sessionData)
 {
     // need to use write connection to get the most fresh DB sessions
     $bindValues = ['session_id' => $sessionId];
     $select = $this->_write->select()->from($this->_sessionTable)->where('session_id = :session_id');
     $exists = $this->_write->fetchOne($select, $bindValues);
     // encode session serialized data to prevent insertion of incorrect symbols
     $sessionData = base64_encode($sessionData);
     $bind = ['session_expires' => time(), 'session_data' => $sessionData];
     if ($exists) {
         $this->_write->update($this->_sessionTable, $bind, ['session_id=?' => $sessionId]);
     } else {
         $bind['session_id'] = $sessionId;
         $this->_write->insert($this->_sessionTable, $bind);
     }
     return true;
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:24,代码来源:DbTable.php

示例4: removeNode

 /**
  * @param Node $node
  * @return $this
  * @throws \Exception
  */
 public function removeNode($node)
 {
     // For reorder old node branch
     $dataReorderOld = [$this->_orderField => new \Zend_Db_Expr($this->_conn->quoteIdentifier($this->_orderField) . '-1')];
     $conditionReorderOld = $this->_conn->quoteIdentifier($this->_parentField) . '=' . $node->getData($this->_parentField) . ' AND ' . $this->_conn->quoteIdentifier($this->_orderField) . '>' . $node->getData($this->_orderField);
     $this->_conn->beginTransaction();
     try {
         $condition = $this->_conn->quoteInto("{$this->_idField}=?", $node->getId());
         $this->_conn->delete($this->_table, $condition);
         // Update old node branch
         $this->_conn->update($this->_table, $dataReorderOld, $conditionReorderOld);
         $this->_conn->commit();
     } catch (\Exception $e) {
         $this->_conn->rollBack();
         throw new \Exception('Can\'t remove tree node');
     }
     parent::removeNode($node);
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:Db.php

示例5: updateSuffixForUrlRewrites

 /**
  * Update suffix for url rewrites
  *
  * @return $this
  */
 protected function updateSuffixForUrlRewrites()
 {
     $map = [ProductUrlPathGenerator::XML_PATH_PRODUCT_URL_SUFFIX => ProductUrlRewriteGenerator::ENTITY_TYPE, CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX => CategoryUrlRewriteGenerator::ENTITY_TYPE];
     if (!isset($map[$this->getPath()])) {
         return $this;
     }
     $dataFilter = [UrlRewrite::ENTITY_TYPE => $map[$this->getPath()]];
     $storesIds = $this->getStoreIds();
     if ($storesIds) {
         $dataFilter[UrlRewrite::STORE_ID] = $storesIds;
     }
     $entities = $this->urlFinder->findAllByData($dataFilter);
     $oldSuffixPattern = '~' . preg_quote($this->getOldValue()) . '$~';
     $suffix = $this->getValue();
     foreach ($entities as $urlRewrite) {
         $bind = $urlRewrite->getIsAutogenerated() ? [UrlRewrite::REQUEST_PATH => preg_replace($oldSuffixPattern, $suffix, $urlRewrite->getRequestPath())] : [UrlRewrite::TARGET_PATH => preg_replace($oldSuffixPattern, $suffix, $urlRewrite->getTargetPath())];
         $this->connection->update(DbStorage::TABLE_NAME, $bind, $this->connection->quoteIdentifier(UrlRewrite::URL_REWRITE_ID) . ' = ' . $urlRewrite->getUrlRewriteId());
     }
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:25,代码来源:Suffix.php

示例6: updateDocument

 /**
  * Updates document rows with specified data based on a WHERE clause
  *
  * @param mixed $document
  * @param array $bind
  * @param mixed $where
  * @return int
  */
 public function updateDocument($document, array $bind, $where = '')
 {
     return $this->resourceAdapter->update($document, $bind, $where);
 }
开发者ID:victor-v-rad,项目名称:data-migration-tool,代码行数:12,代码来源:Mysql.php


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