You are here

function mongodb_collection_name in MongoDB 7

Same name and namespace in other branches
  1. 6 mongodb.module \mongodb_collection_name()

Returns the name to use for the collection.

Also works with prefixes and simpletest.

Parameters

string $name: The base name for the collection.

Return value

string Unlike the base name, the returned name works with prefixes and simpletest.

3 calls to mongodb_collection_name()
MongoDBQueue::claimItem in mongodb_queue/mongodb_queue.inc
Claim an item in the queue for processing.
mongodb_collection in ./mongodb.module
mongodb_next_id in ./mongodb.module
Return the next id in a sequence.

File

./mongodb.module, line 286
Contains the main module connecting Drupal to MongoDB.

Code

function mongodb_collection_name($name) {
  static $simpletest_prefix;

  // We call this function earlier than the database is initialized so we would
  // read the parent collection without this.
  if (!isset($simpletest_prefix)) {
    if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/^(simpletest\\d+);/", $_SERVER['HTTP_USER_AGENT'], $matches)) {
      $simpletest_prefix = $matches[1];
    }
    else {
      $simpletest_prefix = '';
    }
  }

  // However, once the test information is initialized, simpletest_prefix
  // is no longer needed.
  if (!empty($GLOBALS['drupal_test_info']['test_run_id'])) {
    $simpletest_prefix = $GLOBALS['drupal_test_info']['test_run_id'];
  }
  return $simpletest_prefix . $name;
}