Mongo
PHP Manual

Changelog

The following changes have been made to classes/functions/methods of this extension.

MongoDB PHP Driver 1.3.0

The 1.3 series introduced several major changes to the extension such as completely rewritten connection handling (and removal of the pooling mechanism), support for ReadPreferences and change the default WriteConcerns to be acknowledged by introducing a new class MongoClient which serves as a replacement class for the now deprecated Mongo class.

The driver now also supports connecting to multiple mongos instances (the Mongo Shard router) for loadbalancing.

Other enhancements include improved logging for easier connection handling debugging with MongoLog and support for the » Aggregation Framework via the MongoCollection::aggregate() method.

Changes to existing methods

Following is a list of all improvements to existing methods since their inception.

VersionFunctionDescription
1.5.0MongoBinData::__constructThe default changed from 2 (MongoBinData::BYTE_ARRAY) to 0 (MongoBinData::GENERIC).
 MongoCollection::aggregateAdded optional options argument
 MongoCollection::batchInsertRenamed the "wtimeout" option to "wTimeoutMS".
 MongoCollection::batchInsertRenamed the "timeout" option to "socketTimeoutMS".
 MongoCollection::insertRenamed the "timeout" option to "socketTimeoutMS".
 MongoCollection::insertRenamed the "wtimeout" option to "wTimeoutMS".
 MongoCollection::removeRenamed the "timeout" option to "socketTimeoutMS".
 MongoCollection::removeRenamed the "wtimeout" option to "wTimeoutMS".
 MongoCollection::saveRenamed the "timeout" option to "socketTimeoutMS".
 MongoCollection::saveRenamed the "wtimeout" option to "wTimeoutMS".
 MongoCollection::toIndexStringThis method has been deprecated.
 MongoCollection::updateRenamed the "wtimeout" option to "wTimeoutMS".
 MongoCollection::updateRenamed the "timeout" option to "socketTimeoutMS".
 MongoCursor::slaveOkayThis method has been deprecated in favour of MongoCursor::setReadPreference and .
1.4.5MongoCursor::batchSizeBefore 1.4.5, this method would throw an MongoCursorException if the cursor had already started iterating.
1.4.0MongoClient::__constructAdded the "wTimeoutMS" option has replacement for "wTimeout".
 MongoCursor::hintThe index argument now supports index names as string values. In versions before 1.4.0, only array or object values were accepted.
 MongoCursor::setFlagSupport for flag 3 (OPLOG_REPLAY) is added. Versions before 1.4.0 would throw a warning saying that the flag is unsupported.
 MongoDB::createCollectionIn versions before 1.4.0, the options were all arguments to the method. The function synopsis in those older versions is: public MongoCollectionMongoDB::createCollection stringname boolcappedFALSE intsize0 intmax0 The meaning of the options is the same as described under the options argument above.
1.3.4MongoClient::__constructAdded the "connectTimeoutMS" and "socketTimeoutMS" options.
1.3.3MongoClient::getReadPreferenceThe return value has changed to be consistent with MongoClient::setReadPreference. The type value was changed from a number to a string, type_string was removed, and tagsets now expresses tags as key/value pairs instead of colon-delimited strings.
 MongoCollection::getReadPreferenceThe return value has changed to be consistent with MongoCollection::setReadPreference. The type value was changed from a number to a string, type_string was removed, and tagsets now expresses tags as key/value pairs instead of colon-delimited strings.
 MongoDB::getReadPreferenceThe return value has changed to be consistent with MongoDB::setReadPreference. The type value was changed from a number to a string, type_string was removed, and tagsets now expresses tags as key/value pairs instead of colon-delimited strings.
1.3.0MongoClient::closeThe connection parameter to this function was added in 1.3.0. Before that, only the write connection would be closed by this method.
 MongoClient::__constructAdded the "readPreference", "readPreferenceTags", "w" and "wTimeout" options.
 MongoCollection::ensureIndexThe options parameter no longer accepts a boolean to signify a unique index. Instead, this now has to be done with array('unique' => true).
 MongoCollection::insertThe options parameter no longer accepts a boolean to signify a acknowledged write. Instead, this now has to be done with array('w' => 1) (The default behaviour of MongoClient).
 MongoCollection::removeThe options parameter no longer accepts a boolean to signify "justOne". Instead, this now has to be done with array('justOne' => true).
 MongoCollection::updateThe options parameter no longer accepts a boolean to signify an upsert. Instead, this now has to be done with array('upsert' => true).
 MongoDB::listCollectionsAdded the includeSystemCollections parameter.
 MongoGridFSCursor::keyThe document's _id is returned as a string value, since the key should be unique. Pre-1.3.0, filename was returned.
1.2.11Mongo::getPoolSizeEmits E_DEPRECATED when used.
 Mongo::getSlaveEmits E_DEPRECATED when used.
 Mongo::getSlaveOkayEmits E_DEPRECATED when used.
 Mongo::poolDebugEmits E_DEPRECATED when used.
 Mongo::setSlaveOkayEmits E_DEPRECATED when used.
 Mongo::switchSlaveEmits E_DEPRECATED when used.
 MongoBinData::__constructEmits E_DEPRECATED when the second argument is not used. The default value for type may change in the near future.
 MongoCollection::ensureIndexEmits E_DEPRECATED when options is scalar.
 MongoCollection::getSlaveOkayEmits E_DEPRECATED when used.
 MongoCollection::groupEmits E_DEPRECATED when options is scalar.
 MongoCollection::removeEmits E_DEPRECATED when options is scalar.
 MongoCollection::setSlaveOkayEmits E_DEPRECATED when used.
 MongoCollection::updateEmits E_DEPRECATED when options is scalar.
 MongoCursor::doQueryEmits E_DEPRECATED when used.
 MongoDB::authenticateEmits E_DEPRECATED when used. Please pass in the authentication details to the constructor.
 MongoDB::forceErrorEmits E_DEPRECATED when used.
 MongoDB::getSlaveOkayEmits E_DEPRECATED when used.
 MongoDB::prevErrorEmits E_DEPRECATED when used.
 MongoDB::resetErrorEmits E_DEPRECATED when used.
 MongoDB::setSlaveOkayEmits E_DEPRECATED when used.
 MongoPool::getSizeEmits E_DEPRECATED when used.
 MongoPool::infoEmits E_DEPRECATED when used.
 MongoPool::setSizeEmits E_DEPRECATED when used.
1.2.10MongoClient::getHostsSupport for non-replicasets was added. The returned array elements now also include the hostname and port.
1.2.7MongoCollection::batchInsertAdded "continueOnError" option.
1.2.5MongoGridFS::storeUploadChanged second parameter to an array of metadata. Pre-1.2.5, the second parameter was an optional string overriding the filename.
1.2.0MongoClient::closeBefore version 1.2.0 the driver would not use persistent connections by default, and all connections would be closed as soon as a MongoDB connection went out if scope. Since version 1.2.0 this is no longer the case and it is a bad idea to call close as you might end up overloading the server with connections under high load.
 MongoClient::__constructAdded the "username" and "password" options. Removed the "persist" option, as all connections are now persistent. It can still be used, but it doesn't affect anything. "persist" If the connection should be persistent. If set, the connection will be persistent. The string representation of the value is used as an ID for the connection, so two instances of MongoClient that are initialized with array("persist" => "foobar") will share the same database connection, whereas an instance initialized with array("persist" => "barbaz") will use a different database connection. The "replicaSet" option now takes a string, not a boolean.
 MongoCollection::ensureIndexAdded "timeout" option.
 MongoCollection::insertAdded "timeout" option.
 MongoCollection::removeAdded "timeout" option.
 MongoCollection::saveAdded "timeout" option.
 MongoCollection::updateAdded "timeout" option.
 MongoDB::commandAdded options parameter with a single option: "timeout".
1.1.0MongoCursor::infoAdded a number of other fields, including id (the cursor id), at (the driver's counter of which document is current), numReturned (the number returned by the server in the current batch), and server (which server the query was sent to—useful in conjunction with .
1.0.11MongoCollection::ensureIndexThe "safe" option will trigger a primary failover, if necessary. MongoException will be thrown if the index name (either generated or set) is longer than 128 bytes.
 MongoCollection::insertDisconnects on "not master" errors if "safe" is set.
 MongoCollection::removeDisconnects on "not master" errors if "safe" is set.
 MongoCollection::saveDisconnects on "not master" errors if "safe" is set.
 MongoCollection::updateDisconnects on "not master" errors if "safe" is set.
1.0.10MongoCursor::infoAdded started_iterating field, a boolean indicating if cursor is pre- or post-query.
1.0.9MongoClient::__constructAdded the "replicaSet" option.
 MongoCollection::batchInsertAdded ability to pass integers to the "safe" option, which previously only accepted booleans. Added "fsync" option.
 MongoCollection::insertAdded ability to pass integers to the "safe" option, which previously only accepted booleans. Added "fsync" option. The return type was changed to be an array containing error information if the "safe" option is used. Otherwise, a boolean is returned as before.
 MongoCollection::removeAdded ability to pass integers to the "safe" option, which previously only accepted booleans. Added "fsync" option. The return type was changed to be an array containing error information if the "safe" option is used. Otherwise, a boolean is returned as before.
 MongoCollection::saveAdded ability to pass integers to the "safe" option, which previously only accepted booleans. Added "fsync" option.
 MongoCollection::updateAdded ability to pass integers to the "safe" option, which previously only accepted booleans. Added "fsync" option. The return type was changed to be an array containing error information if the "safe" option is used. Otherwise, a boolean is returned as before.
1.0.7MongoCollection::countAdded limit and skip parameters.
1.0.5MongoCollection::batchInsertAdded options parameter.
 MongoCollection::ensureIndexAdded the "name" option to override index name creation.
 MongoCollection::insertChanged second parameter to be an array of options. Pre-1.0.5, the second parameter was a boolean indicating the "safe" option.
 MongoCollection::removeChanged second parameter to be an array of options. Pre-1.0.5, the second parameter was a boolean indicating the "safe" option.
 MongoCollection::saveAdded options parameter.
 MongoCollection::updateAdded "safe" option.
1.0.2MongoClient::__constructChanged constructor to take an array of options. Pre-1.0.2, the constructor took the following parameters: server The server name. connect Optional boolean parameter specifying if the constructor should connect to the database before returning. Defaults to TRUE. persistent If the connection should be persistent. paired If the connection should be paired.
 MongoCollection::ensureIndexChanged options parameter from boolean to array. Pre-1.0.2, the second parameter was an optional boolean value specifying a unique index.
1.0.1MongoCollection::insertThrow a MongoCursorException if the "safe" option is set and the insert fails.
 MongoCollection::updateChanged options parameter from boolean to array. Pre-1.0.1, the second parameter was an optional boolean value specifying an upsert.

Mongo
PHP Manual