当前位置: 首页>>代码示例>>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;未经允许,请勿转载。