You are here

function computing_load_record in Drupal Computing 7

Load one record object according to its id. Fields 'input' and 'output' are byte strings. Caller functions are responsible to unserialize or do other things.

Parameters

$id:

2 calls to computing_load_record()
ComputingTestCase::testCreateUpdateCommand in ./computing.test
computing_load_output_json in ./computing.module

File

./computing.module, line 216

Code

function computing_load_record($id, $fields = NULL) {
  if ($fields == NULL) {

    //$record = db_query("SELECT * FROM {computing_record} WHERE id = :id", array(':id' => $id))->fetchObject();

    //return $record ? $record : NULL;  // return NULL rather than FALSE
    $fields = array();
  }
  else {
    if (!is_array($fields)) {
      $fields = array(
        $fields,
      );
    }

    // validate fields.
    $schema = drupal_get_schema('computing_record');
    $valid_fields = array_keys($schema['fields']);
    $fields = array_intersect($fields, $valid_fields);
  }
  return db_select('computing_record', 'c')
    ->fields('c', $fields)
    ->condition('id', $id)
    ->execute()
    ->fetchObject();
}