Drupal dynamic query

Public

Drupal dynamic query

</> CopyGet raw version
php
  1. $query = db_select('users', 'u');
  2.  
  3. $query
  4. ->condition('u.uid', 0, '<>')
  5. ->fields('u', array('uid', 'name', 'status', 'created', 'access'))
  6. ->range(0, 50);
  7.  
  8. $result = $query->execute();
  9.  
  10. //The above is roughly equivalent to
  11. $result = db_query("SELECT uid, name, status, created, access FROM {users} u WHERE uid <> 0 LIMIT 50 OFFSET 0");
  12.