You are here

function _drush_mongodb_connect in MongoDB 6

Same name and namespace in other branches
  1. 7 mongodb.drush.inc \_drush_mongodb_connect()

Returns the basic shell command string.

3 calls to _drush_mongodb_connect()
drush_mongodb_cli in ./mongodb.drush.inc
Drush callback; Start the mongodb shell.
drush_mongodb_connect in ./mongodb.drush.inc
Drush callback; Return the connect string.
drush_mongodb_query in ./mongodb.drush.inc
Drush callback; Execute a query against a mongodb.

File

./mongodb.drush.inc, line 124
Provide Drush integration for MongoDB.

Code

function _drush_mongodb_connect($alias) {
  $connections = variable_get('mongodb_connections', array());
  $connections += array(
    'default' => array(
      'host' => 'localhost',
      'db' => 'drupal',
    ),
  );
  if (!isset($connections[$alias])) {
    $alias = 'default';
  }
  $connection = $connections[$alias];
  $host = $connection['host'];
  $db = $connection['db'];
  $query = $host;
  $query .= '/' . $db;
  $command = 'mongo ' . $query;
  return $command;
}