db_query_range

  1. drupal
    1. 4.7 database.mysqli.inc
    2. 4.7 database.pgsql.inc
    3. 4.7 database.mysql.inc
    4. 5 database.mysqli.inc
    5. 5 database.pgsql.inc
    6. 5 database.mysql.inc
    7. 6 database.mysqli.inc
    8. 6 database.mysql.inc
    9. 6
    10. 7 database.inc
Versions
4.7 – 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.

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 %%.

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

$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.

Related topics

▾ 45 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.
batch_example_batch_1 in examples/batch_example/batch_example.module
Batch 1 : Load 100 times the node with the lowest nid
batch_example_op_2 in examples/batch_example/batch_example.module
Batch operation for batch 2 : load all nodes, 5 by five This is a multipart operation, using the
batch_test_update_1 in examples/batch_example/batch_example.install
blogapi_blogger_get_recent_posts in drupal/modules/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…
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.
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().
hook_update_index in developer/hooks/core.php
Update Drupal's full-text index for this module.
hook_update_N in developer/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().
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.
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.
statistics_title_list in drupal/modules/statistics/statistics.module
Returns all time or today top or last viewed node(s).
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_select_nodes in drupal/modules/taxonomy/taxonomy.module
Finds all nodes that match selected taxonomy conditions.
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().
_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.
_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.
_node_access_rebuild_batch_operation in drupal/modules/node/node.module
Batch operation for node_access_rebuild_batch.
_token_example_get_comment in examples/token_example/token_example.module
Build a list of available comments.
_token_example_get_node in examples/token_example/token_example.module
Build a list of available content.
_token_example_get_user in examples/token_example/token_example.module
Build a list of availalbe user accounts.

Code

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

<?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);
}
?>