You are here

function computing_get_last_command in Drupal Computing 7

Retrieve the last command of the give app/command.

Parameters

$app:

$command:

bool $success: whether to retrieve the successful command only with status=='OKOK':

Return value

int the computing record id matching the condition.

1 call to computing_get_last_command()
ComputingTestCase::testCreateUpdateCommand in ./computing.test

File

./computing.module, line 146

Code

function computing_get_last_command($app, $command, $success = TRUE, $uid = NULL, $nid = NULL) {
  $query = db_select('computing_record', 'c');
  $query
    ->fields('c', array(
    'id',
  ))
    ->condition('app', $app)
    ->condition('command', $command)
    ->orderBy('updated', 'DESC')
    ->orderBy('id', 'DESC')
    ->range(0, 1);
  if ($success) {
    $query
      ->condition('status', 'OKOK');
  }
  if ($uid !== NULL) {
    $query
      ->condition('uid', $uid);
  }
  if ($nid !== NULL) {
    $query
      ->condition('nid', $nid);
  }
  return $query
    ->execute()
    ->fetchField();
}