db_next_id

function db_next_id

db_next_id($existing_id = 0)

Retrieves a unique id.

Use this function if for some reason you can't use a serial field. Using a serial field is preferred, and InsertQuery::execute() returns the value of the last ID inserted.

Parameters

$existing_id: After a database import, it might be that the sequences table is behind, so by passing in a minimum ID, it can be assured that we never issue the same ID.

Return value

An integer number larger than any number returned before for this sequence.

Related topics

File

includes/database/database.inc, line 2689
Core systems for the database layer.

Code

function db_next_id($existing_id = 0) {
  return Database::getConnection()->nextId($existing_id);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!database!database.inc/function/db_next_id/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部