Skip to content

Instantly share code, notes, and snippets.

@mrsinguyen
Created June 6, 2010 04:44
Show Gist options
  • Save mrsinguyen/427301 to your computer and use it in GitHub Desktop.
Save mrsinguyen/427301 to your computer and use it in GitHub Desktop.
The Drupal Dynamic Query
<?php
$query = db_select('users', 'u');
$query
->condition('u.uid', 0, '<>')
->fields('u', array('uid', 'name', 'status', 'created', 'access'))
->range(0, 50);
$result = $query->execute();
//The above is roughly equivalent to
$result = db_query("SELECT uid, name, status, created, access FROM {users} u WHERE uid <> 0 LIMIT 50 OFFSET 0");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment