You are here

public static function MostPopularLastRun::fetch in Drupal Most Popular 7

Same name and namespace in other branches
  1. 6 classes/lastrun.php \MostPopularLastRun::fetch()

Fetches the last run data for the given service and interval.

If there is not yet any saved data for this service and interval, this function creates and returns new data.

Parameters

integer $sid: The service ID.

integer $iid: The interval ID.

Return value

MostPopularLastRun The data for the last time the service was run, or a new object if the service has not yet run.

File

classes/lastrun.php, line 213
Defines a wrapper for the mostpopular_last_run table.

Class

MostPopularLastRun
@file Defines a wrapper for the mostpopular_last_run table.

Code

public static function fetch($sid, $iid) {
  $out = array();
  $sql = 'SELECT * FROM {' . self::$table . '} WHERE sid = %d AND iid = %d';
  $result = db_query($sql, (int) $sid, (int) $iid);
  if ($row = db_fetch_object($result)) {
    return new MostPopularLastRun($row);
  }
  return self::create($sid, $iid);
}