You are here

function _drush_mongodb_connect in MongoDB 7

Same name and namespace in other branches
  1. 6 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 136
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'];
  $host = preg_replace('@^mongodb://@', '', $host);
  $db = $connection['db'];
  $query = $host;
  $query .= '/' . $db;
  $command = 'mongo ' . $query;
  return $command;
}