本文整理汇总了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);
}
示例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);
}
}
示例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;
}