1 batch_example.module batch_example_lowest_nid()

Utility function - simply queries and loads the lowest nid.

Return value

int|NULL A nid or NULL if there are no nodes.

Related topics

File

modules/examples/batch_example/batch_example.module, line 289
Outlines how a module can use the Batch API.

Code

function batch_example_lowest_nid() {
  $select = db_select('node', 'n')
    ->fields('n', array('nid'))
    ->orderBy('n.nid', 'ASC')
    ->extend('PagerDefault')
    ->limit(1);
  $nid = $select->execute()->fetchField();
  return $nid;
}