You are here

public function Framework::latestId in Realistic Dummy Content 7.2

Same name and namespace in other branches
  1. 8.2 api/src/Framework/Framework.php \Drupal\realistic_dummy_content_api\Framework\Framework::latestId()
  2. 3.x api/src/Framework/Framework.php \Drupal\realistic_dummy_content_api\Framework\Framework::latestId()

Retrieve the latest entity id (for example node nid).

Parameters

string $table: A database table, for example node or users.

string $key: A database key, for example nid or uid.

Return value

int The latest key (node nid or user uid) in the database.

Throws

Exception

File

api/src/Framework/Framework.php, line 195

Class

Framework
The entry point for the framework.

Namespace

Drupal\realistic_dummy_content_api\Framework

Code

public function latestId($table = 'node', $key = 'nid') {
  return db_query("SELECT {$key} FROM {$table} ORDER BY {$key} DESC LIMIT 1")
    ->fetchField();
}