public function Framework::latestId in Realistic Dummy Content 3.x
Same name and namespace in other branches
- 8.2 api/src/Framework/Framework.php \Drupal\realistic_dummy_content_api\Framework\Framework::latestId()
- 7.2 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
1 call to Framework::latestId()
- Drupal8::createDummyNode in api/
src/ Framework/ Drupal8.php - Create a dummy node.
File
- api/
src/ Framework/ Framework.php, line 204
Class
- Framework
- The entry point for the framework.
Namespace
Drupal\realistic_dummy_content_api\FrameworkCode
public function latestId($table = 'node', $key = 'nid') {
// @phpstan-ignore-next-line
return \Drupal::database()
->query("SELECT {$key} FROM {$table} ORDER BY {$key} DESC LIMIT 1")
->fetchField();
}