You are here

public function ResourceFactory::_load in D7 Media 6

Return the first matching file in the files table. This is a simple single object loader it in combination with the static $files variable allows all drupal file objects to also act as factories and share the same static cache.

Parameters

string key (required) database column to use in where condition.:

int|string value (required) the value of the column to use in the where condition.:

Return value

object|bool A Drupal file object or FALSE if a file was not found.

See also

drupal_file::load(), drupal_file::load_path()

2 calls to ResourceFactory::_load()
ResourceFactory::loadId in resource/resource.module
Load a file object from the database by id.
ResourceFactory::loadUrl in resource/resource.module
Load a file object from the database by path.

File

resource/resource.module, line 495
Resource API for Drupal, a replacement for files.

Class

ResourceFactory

Code

public function _load($column, $value) {

  // set a cache id based on key and value so we can statically cache
  // all simple loads.
  $cid = $column . '::' . $value;
  if (empty(self::$files[$cid])) {
    $resource = db_fetch_object(db_query('SELECT f.* FROM {resource} r WHERE r.%s = %d', $column, $value));
    $resource = new Resource($r);
  }
  module_invoke_all('resource_load', $r);
  self::$resources[$cid] = $r;

  // Files are not cloned, because there is in fact only one.
  return self::$resources[$cid];
}