當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AdapterInterface::lastInsertId方法代碼示例

本文整理匯總了PHP中Magento\Framework\DB\Adapter\AdapterInterface::lastInsertId方法的典型用法代碼示例。如果您正苦於以下問題:PHP AdapterInterface::lastInsertId方法的具體用法?PHP AdapterInterface::lastInsertId怎麽用?PHP AdapterInterface::lastInsertId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\DB\Adapter\AdapterInterface的用法示例。


在下文中一共展示了AdapterInterface::lastInsertId方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetVersion

 /**
  * Test for getVersion() method
  *
  * @return void
  */
 public function testGetVersion()
 {
     $model = $this->objectManager->create('Magento\\Framework\\Mview\\View\\Changelog', ['resource' => $this->resource]);
     $model->setViewId('test_view_id_2');
     $model->create();
     $this->assertEquals(0, $model->getVersion());
     $changelogName = $this->resource->getTableName($model->getName());
     $this->connection->insert($changelogName, [$model->getColumnName() => mt_rand(1, 200)]);
     $this->assertEquals($this->connection->lastInsertId($changelogName, 'version_id'), $model->getVersion());
     $model->drop();
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:16,代碼來源:ChangelogTest.php

示例2: appendChild

 /**
  * @param Node $data
  * @param Node $parentNode
  * @param Node $prevNode
  * @return Node
  */
 public function appendChild($data, $parentNode, $prevNode = null)
 {
     $orderSelect = $this->_conn->select();
     $orderSelect->from($this->_table, new \Zend_Db_Expr('MAX(' . $this->_conn->quoteIdentifier($this->_orderField) . ')'))->where($this->_conn->quoteIdentifier($this->_parentField) . '=' . $parentNode->getId());
     $order = $this->_conn->fetchOne($orderSelect);
     $data[$this->_parentField] = $parentNode->getId();
     $data[$this->_levelField] = $parentNode->getData($this->_levelField) + 1;
     $data[$this->_orderField] = $order + 1;
     $this->_conn->insert($this->_table, $data);
     $data[$this->_idField] = $this->_conn->lastInsertId();
     return parent::appendChild($data, $parentNode, $prevNode);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:18,代碼來源:Db.php

示例3: _createMageCustomers

 /**
  * Create $total Magento customers with emails "customer_$i[at]test.com" and save mapping to MageId into
  * $this->_testMageCustomers & $this->_testMageCustomersReverted
  *
  * ATTENTION: There is warning "Test method "_createMageCustomers" in test class "..." is not public."
  * in case of method's visibility is 'protected' (after $total argument was added).
  *
  * @param int $total total count of the Magento customers to be created.
  */
 protected function _createMageCustomers($total = 13)
 {
     $tbl = $this->_resource->getTableName(Cfg::ENTITY_MAGE_CUSTOMER);
     for ($i = 1; $i <= $total; $i++) {
         $email = "customer_{$i}@test.com";
         $this->_conn->insert($tbl, [Cfg::E_CUSTOMER_A_EMAIL => $email]);
         $id = $this->_conn->lastInsertId($tbl);
         $this->_mapCustomerMageIdByIndex[$i] = $id;
         $this->_mapCustomerIndexByMageId[$id] = $i;
         $this->_logger->debug("New Magento customer #{$i} is added with ID={$id} ({$email}).");
     }
     $this->_logger->debug("Total {$total} customer were added to Magento.");
 }
開發者ID:praxigento,項目名稱:mobi_mod_mage2_core,代碼行數:22,代碼來源:BaseIntegrationTest.php

示例4: clear

 /**
  * Clear table and add root element
  *
  * @param array $data
  * @return string
  */
 public function clear($data = [])
 {
     // clearing table
     $this->_db->query('TRUNCATE ' . $this->_table);
     // prepare data for root element
     $data[$this->_pid] = 0;
     $data[$this->_left] = 1;
     $data[$this->_right] = 2;
     $data[$this->_level] = 0;
     try {
         $this->_db->insert($this->_table, $data);
     } catch (\PDOException $e) {
         echo $e->getMessage();
     }
     return $this->_db->lastInsertId();
 }
開發者ID:IlyaGluschenko,項目名稱:test001,代碼行數:22,代碼來源:Tree.php

示例5: getNextValue

 /**
  * Retrieve next value
  *
  * @return string
  */
 public function getNextValue()
 {
     $this->adapter->insert($this->meta->getSequenceTable(), []);
     $this->lastIncrementId = $this->adapter->lastInsertId($this->meta->getSequenceTable());
     return $this->getCurrentValue();
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:11,代碼來源:Sequence.php


注:本文中的Magento\Framework\DB\Adapter\AdapterInterface::lastInsertId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。