mongodb/mongo-php-driver — pull request #589 by bjori (2014-02-21 21:21:53+00:00)
Title: PHP-990: MongoWriteBatch API - BETA

Please review this userland API suggestion, as it will become (almost verbatim!) the API

collection = $collection;
if (!in_array($op, array(0, 1, 3))) {
throw MongoException();
}
$this->op = $op;
_internal_initialize_{$this->writeop}();
}

/* bool */ function add(array $item) {
if (!_internal_check_missing_keys($item, $this->op)) {
throw MongoException("Missing key 'x'");
}
_internal_add_item($item);
}

final /* array */ function execute(array $writeConcern) {
_internal_execute($writeConcern);
return _internal_read_server_response();
}
}

class MongoInsertBatch extends MongoWriteBatch {
function __construct($collection) {
parent::__construct($collection, self::OP_INSERT);
}
}

class MongoUpdateBatch extends MongoWriteBatch {
function __construct($collection) {
parent::__construct($collection, self::OP_UPDATE);
}
}

class MongoDeleteBatch extends MongoWriteBatch {
function __construct($collection) {
parent::__construct($collection, self::OP_DELETE);
}
}