function batch_example_lowest_nid in Examples for Developers 7
Utility function - simply queries and loads the lowest nid.
Return value
int|NULL A nid or NULL if there are no nodes.
Related topics
2 calls to batch_example_lowest_nid()
- batch_example_batch_1 in batch_example/batch_example.module 
- Batch 1 definition: Load the node with the lowest nid 1000 times.
- batch_example_simple_form in batch_example/batch_example.module 
- Form builder function to allow choice of which batch to run.
File
- batch_example/batch_example.module, line 291 
- 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;
}