This project is not covered by Drupal’s security advisory policy.

Query tools is a small API module to make it easier to query and save Drupal objects.

Unlike other frameworks, Drupal lacks some tools for accessing and saving data in a granular or property-based way.

Currently it does the following:

  • Retrieve an array of nodes based on CCK field values
  • Save a node by passing a field value

Query tools currently only supports Nodes.

You should not install this module unless you wish to use its API in your own code, or you are instructed by another module.

Query Tools allows you to save or retrieve data without needing to go through the process of building complete Drupal objects.

Query Tools is somewhat similar to the ORM module (, however Query Tools is not an ORM implementation.


The API can be invoked directly through the class interface, or via a functional wrapper.

Invoke the class directly

// Type of query to work with, usually 'node
$query = query_tools_query('node');

// Load existing data into the object

// Set some field values
$query->set_field('field_name_one', array('0' => array('value' => $value_to_insert_foo)));
$query->set_field('field_name_two', array('0' => array('value' => $value_to_insert_bar)));

// Save the result
$result = $query->save();

Load a node

Load a node object from the database, using both core node fields and CCK fields.
Returns a fully-populated node object.

An array of conditions for core node fields to match against in the database query.
Since we also have the CCK conditions, this parameter can also be NULL.

An array of conditions for CCK fields to match against in the database query

Which numbered revision to load. Defaults to the current version.


$node = query_tools_node_find(
  array('type' => 'event'),
  array('event_type' => 'conference')

Update a nodes values

Allows you to pass CCK field values through to a given node and save them.
Multiple field values can be provided, but the 'value' must be a fully populated CCK field object. Query Tools does no field detection currently. For example, for a Nodereference field, 'value' should be replaced with 'nid'.

    'field_name' => array(
      '#type' => 'cck',
      '#field_name' => 'field_name',
      '#values' => array(
        '0' => array(
          'value' => 'A fully populated CCK field object',

Project information