You are here

function mongodb_default_write_options in MongoDB 6

Same name and namespace in other branches
  1. 7 mongodb.module \mongodb_default_write_options()

Returns default options for MongoDB write operations.

Parameters

bool $safe: Set it to FALSE for "fire and forget" write operation.

Return value

array Default options for Mongo write operations.

1 call to mongodb_default_write_options()
mongodb_watchdog_watchdog in mongodb_watchdog/mongodb_watchdog.module
Implements hook_watchdog().

File

./mongodb.module, line 336
A library of common mechanisms for modules using MongoDB.

Code

function mongodb_default_write_options($safe = TRUE) {
  if ($safe) {
    if (version_compare(phpversion('mongo'), '1.5.0') == -1) {
      return array(
        'safe' => TRUE,
      );
    }
    else {
      return variable_get('mongodb_write_safe_options', array(
        'w' => 1,
      ));
    }
  }
  else {
    if (version_compare(phpversion('mongo'), '1.3.0') == -1) {
      return array();
    }
    else {
      return variable_get('mongodb_write_nonsafe_options', array(
        'w' => 0,
      ));
    }
  }
}