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


PHP Connection::lastInsertId方法代碼示例

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


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

示例1: insert

 /**
  * Inserts row in a table.
  * @param  mixed array($column => $value)|Traversable for single row insert or TableSelection|string for INSERT ... SELECT
  * @return ActiveRow or FALSE in case of an error or number of affected rows for INSERT ... SELECT
  */
 public function insert($data)
 {
     if ($data instanceof Selection) {
         $data = $data->getSql();
     } elseif ($data instanceof \Traversable) {
         $data = iterator_to_array($data);
     }
     $return = $this->connection->query("INSERT INTO {$this->delimitedName}", $data);
     $this->rows = NULL;
     if (!is_array($data)) {
         return $return->rowCount();
     }
     if (!isset($data[$this->primary]) && ($id = $this->connection->lastInsertId())) {
         $data[$this->primary] = $id;
     }
     return new ActiveRow($data, $this);
 }
開發者ID:rostenkowski,項目名稱:HttpPHPUnit,代碼行數:22,代碼來源:Selection.php

示例2: insert

 /**
  * Inserts row in a table.
  *
  * @param  mixed array($column => $value)|Traversable for single row insert or Selection|string for INSERT ... SELECT
  *
  * @return ActiveRow or FALSE in case of an error or number of affected rows for INSERT ... SELECT
  */
 public function insert($data)
 {
     if ($data instanceof Selection) {
         $data = $data->getSql();
     } elseif ($data instanceof \Traversable) {
         $data = iterator_to_array($data);
     }
     $return = $this->connection->query($this->sqlBuilder->buildInsertQuery(), $data);
     $this->checkReferenced = true;
     if (!is_array($data)) {
         return $return->rowCount();
     }
     if (!isset($data[$this->primary]) && ($id = $this->connection->lastInsertId())) {
         $data[$this->primary] = $id;
         return $this->rows[$id] = $this->createRow($data);
     } else {
         return $this->createRow($data);
     }
 }
開發者ID:TheTypoMaster,項目名稱:SPHERE-Framework,代碼行數:26,代碼來源:Selection.php

示例3: insert

 /**
  * Inserts row in a table.
  * @param  mixed array($column => $value)|Traversable for single row insert or Selection|string for INSERT ... SELECT
  * @return ActiveRow or FALSE in case of an error or number of affected rows for INSERT ... SELECT
  */
 public function insert($data)
 {
     if ($data instanceof Selection) {
         $data = $data->getSql();
     } elseif ($data instanceof \Traversable) {
         $data = iterator_to_array($data);
     }
     $return = $this->connection->query($this->sqlBuilder->buildInsertQuery(), $data);
     $this->checkReferenced = TRUE;
     if (!is_array($data)) {
         return $return->rowCount();
     }
     if (!is_array($this->primary) && !isset($data[$this->primary]) && ($id = $this->connection->lastInsertId($this->getPrimarySequence()))) {
         $data[$this->primary] = $id;
     }
     $row = $this->createRow($data);
     if ($signature = $row->getSignature(FALSE)) {
         $this->rows[$signature] = $row;
     }
     return $row;
 }
開發者ID:genextwebs,項目名稱:dropbox-sample,代碼行數:26,代碼來源:Selection.php


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