db_query_range

Definition

db_query_range($query, $args, $from = 0, $count = 0, $options = array())
includes/database/database.inc, line 1219

Description

Execute an arbitrary query string against the active database, restricted to a specified range.

See also

DatabaseConnection::defaultOptions()

Parameters

$query The prepared statement query to run. Although it will accept both named and unnamed placeholders, named placeholders are strongly preferred as they are more self-documenting.

$args An array of values to substitute into the query. If the query uses named placeholders, this is an associative array in any order. If the query uses unnamed placeholders (?), this is an indexed array and the order must match the order of placeholders in the query string.

$from The first record from the result set to return.

$limit The number of records to return from the result set.

$options An array of options to control how the query operates.

Return value

A prepared statement object, already executed.

Related topics

Namesort iconDescription
Database abstraction layerAllow the use of different database servers using the same code base.

Code

<?php
function db_query_range($query, $args, $from = 0, $count = 0, $options = array()) {
  if (!is_array($args)) {
    $args = func_get_args();
    array_shift($args);
    $count = array_pop($args);
    $from = array_pop($args);
  }
  list($query, $args, $options) = _db_query_process_args($query, $args, $options);

  return Database::getActiveConnection($options['target'])->queryRange($query, $args, $from, $count, $options);
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.