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 (drupal.org/project/orm), however Query Tools is not an ORM implementation.
Usage
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
$query->load($node_id_to_work_with);
// 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();