db_query_range

Versions
5 – 6
db_query_range($query)
7
db_query_range($query, $from, $count, array $args = array(), array $options = array())

Runs a limited-range query in the active database.

Use this as a substitute for db_query() when a subset of the query is to be returned. User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

NOTE: using this syntax will cast NULL and FALSE values to decimal 0, and TRUE values to decimal 1.

Parameters

$query A string containing an SQL query.

... A variable number of arguments which are substituted into the query using printf() syntax. Instead of a variable number of query arguments, you may also pass a single array containing the query arguments. Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose in '') and %%.

$from The first result row to return.

$count The maximum number of result rows to return.

Return value

A database query result resource, or FALSE if the query was not executed correctly.

▾ 79 functions call db_query_range()

aggregator_block in drupal/modules/aggregator/aggregator.module
Implementation of hook_block().
aggregator_page_categories in drupal/modules/aggregator/aggregator.pages.inc
Menu callback; displays all the categories used by the aggregator.
aggregator_page_rss in drupal/modules/aggregator/aggregator.pages.inc
Menu callback; generate an RSS 0.92 feed of aggregator items or categories.
aggregator_page_sources in drupal/modules/aggregator/aggregator.pages.inc
Menu callback; displays all the feeds used by the aggregator.
apachesolr_get_nodes_to_index in contributions/apachesolr/apachesolr.module
Returns an array of rows from a query based on an indexing namespace.
blogapi_blogger_get_recent_posts in contributions/blogapi/blogapi.module
Blogging API callback. Returns the latest few postings in a user's blog. $bodies TRUE <a href="http://movabletype.org/docs/mtmanual_programmatic.html#item_mt%2EgetRecentPostTitles"> returns a bandwidth-friendly list</a>.
blog_block in drupal/modules/blog/blog.module
Implementation of hook_block().
blog_feed_last in drupal/modules/blog/blog.pages.inc
Menu callback; displays an RSS feed containing recent blog entries of all users.
blog_feed_user in drupal/modules/blog/blog.pages.inc
Menu callback; displays an RSS feed containing recent blog entries of a given user.
book_update_6000 in drupal/modules/book/book.install
Drupal 5.x to 6.x update.
comment_get_recent in drupal/modules/comment/comment.module
Find a number of recent comments. This is done in two steps. 1. Find the n (specified by $number) nodes that have the most recent comments. This is done by querying node_comment_statistics which has an index on last_comment_timestamp, and is thus a…
comment_get_recent in drupal/modules/comment/comment.module
Find a number of recent comments. This is done in two steps. 1. Find the n (specified by $number) nodes that have the most recent comments. This is done by querying node_comment_statistics which has an index on last_comment_timestamp, and is thus a…
content_storage in contributions/cck/content.module
Handle storage ops for _content_field_invoke_default().
ctools_content_autocomplete_node in contributions/ctools/includes/content.menu.inc
Helper function for autocompletion of node titles.
do_search in drupal/modules/search/search.module
Do a query on the full-text search index for a word or words.
drupal_is_denied in drupal/includes/bootstrap.inc
Perform an access check for a given mask and rule type. Rules are usually created via admin/user/rules page.
feedapi_cron in contributions/feedapi/feedapi.module
Implementation of hook_cron().
forum_block in drupal/modules/forum/forum.module
Implementation of hook_block().
forum_get_forums in drupal/modules/forum/forum.module
Returns a list of all forums for a given taxonomy id
forum_nodeapi in drupal/modules/forum/forum.module
Implementation of hook_nodeapi().
forum_pathauto_bulkupdate in contributions/pathauto/pathauto_taxonomy.inc
Generate aliases for all forums and forum containers without aliases.
forum_pathauto_bulkupdate in contributions/pathauto/pathauto_taxonomy.inc
Generate aliases for all forums and forum containers without aliases.
hook_update_index in documentation/hooks/core.php
Update Drupal's full-text index for this module.
hook_update_N in documentation/hooks/install.php
Perform a single update.
menu_edit_menu_validate in drupal/modules/menu/menu.admin.inc
Validates the human and machine-readable names when adding or editing a menu.
menu_get_item in drupal/includes/menu.inc
Get a router item.
menu_link_children_relative_depth in drupal/includes/menu.inc
Find the depth of an item's children relative to its depth.
menu_nodeapi in drupal/modules/menu/menu.module
Implementation of hook_nodeapi().
nodewords_basic_update_6112 in contributions/nodewords/nodewords_basic/nodewords_basic.install
Implements hook_update_N().
nodewords_custom_pages_edit_validate in contributions/nodewords/nodewords_custom_pages/nodewords_custom_pages.admin.inc
Validate function for the meta tags edit page.
nodewords_custom_pages_update_6101 in contributions/nodewords/nodewords_custom_pages/nodewords_custom_pages.install
Implements hook_update_N().
nodewords_custom_pages_update_6102 in contributions/nodewords/nodewords_custom_pages/nodewords_custom_pages.install
Implements hook_update_N().
nodewords_load_tags in contributions/nodewords/nodewords.module
Load tags from table.
nodewords_update_6113 in contributions/nodewords/nodewords.install
Implements hook_update_N().
nodewords_update_6136 in contributions/nodewords/nodewords.install
Implements hook_update_N().
nodewords_update_6158 in contributions/nodewords/nodewords.install
Implements hook_update_N().
nodewords_update_6159 in contributions/nodewords/nodewords.install
Implements hook_update_N().
node_access in drupal/modules/node/node.module
Determine whether the current user may perform the given operation on the specified node.
node_access in drupal/modules/node/node.module
Determine whether the current user may perform the given operation on the specified node.
node_feed in drupal/modules/node/node.module
A generic function for generating RSS feeds from a set of nodes.
node_update_index in drupal/modules/node/node.module
Implementation of hook_update_index().
pager_query in drupal/includes/pager.inc
Perform a paged database query.
pathauto_token_values in contributions/pathauto/pathauto.module
Implements hook_token_values().
profile_admin_settings_autocomplete in drupal/modules/profile/profile.admin.inc
Retrieve a pipe delimited string of autocomplete suggestions for profile categories
profile_autocomplete in drupal/modules/profile/profile.pages.inc
Callback to allow autocomplete of profile text fields.
realname_ajax_autocomplete_user in contributions/realname/realname.module
Page callback for user autocomplete.
realname_privatemsg_autocomplete in contributions/realname/realname.module
Intercept Privatemsg autocomplete results for usernames.
realname_update_index in contributions/realname/realname.module
Implementation of hook_update_index().
statistics_title_list in drupal/modules/statistics/statistics.module
Returns all time or today top or last viewed node(s).
subpath_alias_url_inbound_alter in contributions/subpath_alias/subpath_alias.module
Implementation of hook_url_inbound_alter().
subpath_alias_url_outbound_alter in contributions/subpath_alias/subpath_alias.module
Implementation of hook_url_outbound_alter().
system_update_6021 in drupal/modules/system/system.install
Migrate the menu items from the old menu system to the new menu_links table.
taxonomy_autocomplete in drupal/modules/taxonomy/taxonomy.pages.inc
Helper function for autocompletion
taxonomy_pathauto_bulkupdate in contributions/pathauto/pathauto_taxonomy.inc
Generate aliases for all categories without aliases.
taxonomy_pathauto_bulkupdate in contributions/pathauto/pathauto_taxonomy.inc
Generate aliases for all categories without aliases.
taxonomy_select_nodes in drupal/modules/taxonomy/taxonomy.module
Finds all nodes that match selected taxonomy conditions.
twitter_cron in contributions/twitter/twitter.module
Implementation of hook_cron()
twitter_cron in contributions/twitter/twitter.module
Implementation of hook_cron()
user_autocomplete in drupal/modules/user/user.pages.inc
Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users.
user_autocomplete in drupal/modules/user/user.pages.inc
Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users.
user_block in drupal/modules/user/user.module
Implementation of hook_block().
views_ajax_autocomplete_user in contributions/views/includes/ajax.inc
Page callback for views user autocomplete
views_ui_autocomplete_tag in contributions/views/includes/admin.inc
Page callback for views tag autocomplete
_blog_post_exists in drupal/modules/blog/blog.module
Helper function to determine if a user has blog posts already.
_comment_update_node_statistics in drupal/modules/comment/comment.module
Updates the comment statistics for a given node. This should be called any time a comment is added, deleted, or updated.
_feedapi_node_purge in contributions/feedapi/feedapi_node/feedapi_node.module
Delete all nodes associated with a feed.
_feedapi_update in contributions/feedapi/feedapi.module
Update feed data of an existing feed
_forum_new in drupal/modules/forum/forum.module
Finds the first unread node for a given forum.
_menu_find_router_path in drupal/includes/menu.inc
Find the router path which will serve this path.
_menu_update_parental_status in drupal/includes/menu.inc
Check and update the has_children status for the parent of a link.
_nodereference_potential_references_standard in contributions/cck/modules/nodereference/nodereference.module
Helper function for _nodereference_potential_references(): referenceable nodes defined by content types.
_nodewords_get_tags_data in contributions/nodewords/nodewords.module
_node_access_rebuild_batch_operation in drupal/modules/node/node.module
Batch operation for node_access_rebuild_batch.
_pathauto_alias_exists in contributions/pathauto/pathauto.inc
Check to see if there is already an alias pointing to a different item.
_pathauto_alias_exists in contributions/pathauto/pathauto.inc
Check to see if there is already an alias pointing to a different item.
_site_map_blogs in contributions/site_map/site_map.module
Render the latest blog authors
_site_map_blogs in contributions/site_map/site_map.module
Render the latest blog authors
_weblinks_get_query in contributions/weblinks/weblinks.module
General database query function.
_weblinks_get_query in contributions/weblinks/weblinks.module
General database query function.

Code

drupal/includes/database.pgsql.inc, line 271

<?php
function db_query_range($query) {
  $args = func_get_args();
  $count = array_pop($args);
  $from = array_pop($args);
  array_shift($args);

  $query = db_prefix_tables($query);
  if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
    $args = $args[0];
  }
  _db_query_callback($args, TRUE);
  $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
  $query .= ' LIMIT '. (int)$count .' OFFSET '. (int)$from;
  return _db_query($query);
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.