©
本文档使用
php.cn手册 发布
对本扩展的类/函数/方法有以下更新。
It supports all new features for MongoDB 2.6, including:
With this release, some driver functionality which was previously documented as deprecated will now formally raise deprecation notices. This includes:
Note:
No previously deprecated features have been removed.
Changes in behaviour:
The 1.4 series introduced fundemental changes in how connections are created to the MongoDB servers. The driver now utilizes PHP native streams, so all normal PHP stream options apply. Furthermore, an experimental Stream Context Support was added.
The 1.4.x series also added support for MongoDB 2.4.x.
The most important improvements however deal with the handling of replica sets, especially nodes that timeout and nodes that are unreachable for various reasons. Besides the improvements to replica set handling, this release addresses issues with read preferences through mongos nodes. It also adds support for SSL enabled connections as well as journal and fsync connection string options.
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.
Following is a list of all improvements to existing methods since their inception.
Version | Function | Description |
---|---|---|
1.6.0 | MongoDB::getCollectionNames | Changed first parameter to be an array of options. Pre-1.6.0, the first parameter was a boolean indicating the "includeSystemCollections" option. |
MongoDB::listCollections | Changed first parameter to be an array of options. Pre-1.6.0, the first parameter was a boolean indicating the "includeSystemCollections" option. | |
1.5.0 | MongoCollection::aggregate | Added optional options argument |
MongoCollection::batchInsert | Added the "wTimeoutMS" option, which replaces "wtimeout". Emits E_DEPRECATED when "wtimeout" is used. Added the "socketTimeoutMS" option, which replaces "timeout". Emits E_DEPRECATED when "timeout" is used. Emits E_DEPRECATED when "safe" is used. | |
MongoCollection::ensureIndex | Renamed the "wtimeout" option to "wTimeoutMS". Emits E_DEPRECATED when "wtimeout" is used. Renamed the "timeout" option to "socketTimeoutMS". Emits E_DEPRECATED when "timeout" is used. Emits E_DEPRECATED when "safe" is used. | |
MongoCollection::findOne | Added optional options argument. | |
MongoCollection::group | Added "maxTimeMS" option. | |
MongoCollection::toIndexString | This method has been deprecated. | |
MongoCollection::update | Added the "wTimeoutMS" option, which replaces "wtimeout". Emits E_DEPRECATED when "wtimeout" is used. Added the "socketTimeoutMS" option, which replaces "timeout". Emits E_DEPRECATED when "timeout" is used. Emits E_DEPRECATED when "safe" is used. | |
MongoCursor::slaveOkay | This method has been deprecated in favour of MongoCursor::setReadPreference and . | |
1.4.5 | MongoCursor::batchSize | Before 1.4.5, this method would throw an MongoCursorException if the cursor had already started iterating. |
1.4.0 | MongoCursor::hint | The index argument now supports index names as string values. In versions before 1.4.0, only array or object values were accepted. |
MongoCursor::setFlag | Support for flag 3 (OPLOG_REPLAY) is added. Versions before 1.4.0 would throw a warning saying that the flag is unsupported. | |
MongoDB::createCollection | 1.4.0以前的版本里,所有选项都是这个方法的参数。之前版本这个方法的签名是这样的: public MongoCollectionMongoDB::createCollection stringname boolcappedFALSE intsize0 intmax0 参数的意义与现在版本的 options 参数相同。 | |
MongoId::__construct | 传入无效字符将抛出异常 | |
1.3.4 | MongoClient::__construct | 添加了 "connectTimeoutMS" 和 "socketTimeoutMS" 选项。 |
MongoCollection::batchInsert | Added "wtimeout" option. | |
MongoCollection::ensureIndex | Added "wtimeout" option. | |
MongoCollection::update | Added "wtimeout" option. | |
1.3.3 | MongoClient::getReadPreference | 返回的值修改为兼容 MongoClient::setReadPreference。 type 的值从数组改成字符串,删除了 type_string,并且 tagsets 现在以键值表示的标签而不是冒号分隔的字符串。 |
MongoCollection::getReadPreference | The 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::getReadPreference | The 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.0 | MongoClient::close | 在 1.3.0 版本中,为这个函数添加了 connection 参数。 在此之前,直邮写入连接才会被这个方法关闭。 |
MongoClient::__construct | 添加了 "readPreference"、 "readPreferenceTags"、"w" 和 "wTimeout" 选项。 | |
MongoCollection::batchInsert | Added "w" option. | |
MongoCollection::ensureIndex | Added "w" option. The options parameter no longer accepts a boolean to signify a unique index. Instead, this now has to be done with array('unique' => true). | |
MongoCollection::insert | options 参数不再接受 boolean 来标识一个确认的写入。 现在,你可以通过 array('w' => 1) 设置( MongoClient 默认的行为) | |
MongoCollection::remove | options 参数不再接受 boolean 值来代表 "justOne"。 现在,必须使用 array('justOne' => true) 作为替代。 | |
MongoCollection::update | Added "w" option. The options parameter no longer accepts a boolean to signify an upsert. Instead, this now has to be done with array('upsert' => true). | |
MongoDB::listCollections | Added the includeSystemCollections parameter. | |
MongoGridFSCursor::key | The document's _id is returned as a string value, since the key should be unique. Pre-1.3.0, filename was returned. | |
1.2.11 | Mongo::getPoolSize | Emits E_DEPRECATED when used. |
Mongo::getSlave | Emits E_DEPRECATED when used. | |
Mongo::getSlaveOkay | Emits E_DEPRECATED when used. | |
Mongo::poolDebug | Emits E_DEPRECATED when used. | |
Mongo::setSlaveOkay | Emits E_DEPRECATED when used. | |
Mongo::switchSlave | Emits E_DEPRECATED when used. | |
MongoBinData::__construct | 没有使用第二个参数时产生 E_DEPRECATED。 type 的默认值在近期的功能里可能会改变。 | |
MongoCollection::ensureIndex | Emits E_DEPRECATED when options is scalar. | |
MongoCollection::getSlaveOkay | Emits E_DEPRECATED when used. | |
MongoCollection::group | Emits E_DEPRECATED when options is scalar. | |
MongoCollection::remove | 当 options 是 scalar 时产生一个 E_DEPRECATED 警告。 | |
MongoCollection::setSlaveOkay | Emits E_DEPRECATED when used. | |
MongoCollection::update | Emits E_DEPRECATED when options is scalar. | |
MongoCursor::doQuery | Emits E_DEPRECATED when used. | |
MongoDB::authenticate | 使用时产生 E_DEPRECATED。 请将验证细节传入到构造器。 | |
MongoDB::forceError | Emits E_DEPRECATED when used. | |
MongoDB::getSlaveOkay | Emits E_DEPRECATED when used. | |
MongoDB::prevError | Emits E_DEPRECATED when used. | |
MongoDB::resetError | Emits E_DEPRECATED when used. | |
MongoDB::setSlaveOkay | Emits E_DEPRECATED when used. | |
MongoPool::getSize | Emits E_DEPRECATED when used. | |
MongoPool::info | Emits E_DEPRECATED when used. | |
MongoPool::setSize | Emits E_DEPRECATED when used. | |
1.2.10 | MongoClient::getHosts | 对非集群的支持。 返回的数组元素现在也包括了 hostname 和 port。 |
1.2.7 | MongoCollection::batchInsert | Added "continueOnError" option. |
1.2.5 | MongoGridFS::storeUpload | Changed second parameter to an array of metadata. Pre-1.2.5, the second parameter was an optional string overriding the filename. |
1.2.0 | MongoClient::close | 在版本 1.2.0 之前,这个驱动默认不会使用持久连接,所有连接会在作用域结束时关闭。 由于版本 1.2.0 情况不再如此,所以调用 close 会是一个坏主意,在服务器有较高负载时可能会造成更高的压力。 |
MongoClient::__construct | 添加了 "username" 和 "password" 选项。 移除了 "persist" 选项,所有的连接都是持久的。它仍旧能够使用,但是不起作用。 "persist" 是否应该是持久连接。如果设置了,连接会是持久连接。 字符形式的值将会用于连接的 ID。所以两个以 array("persist" => "foobar") 初始化的 MongoClient 实例会共享一个数据库连接,以 array("persist" => "barbaz")初始化的实例则使用不同的数据库连接。 "replicaSet" 选项现在支持一个字符串,而不是布尔值。 | |
MongoCollection::ensureIndex | Added "timeout" option. | |
MongoCollection::insert | 增加了 "timeout" 选项。 | |
MongoCollection::remove | 添加 "timeout" 选项。 | |
MongoCollection::save | 增加 "timeout" 选项。 | |
MongoCollection::update | Added "timeout" option. | |
MongoDB::command | 添加 options 参数,和一个选项:"timeout"。 | |
1.1.0 | MongoCursor::info | Added 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.11 | MongoCollection::ensureIndex | The "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::insert | 如果设置了 "safe",出现 "not master" 错误时断开连接。 | |
MongoCollection::remove | 在设置了 "safe" 之后,将在出现 "not master" 错误时断开连接。 | |
MongoCollection::save | 设置 "safe" 时,当出现 "not master" 错误时主动断开连接。 | |
MongoCollection::update | Disconnects on "not master" errors if "safe" is set. | |
1.0.10 | MongoCursor::info | Added started_iterating field, a boolean indicating if cursor is pre- or post-query. |
1.0.9 | MongoClient::__construct | 添加了 "replicaSet" 选项。 |
MongoCollection::batchInsert | Added ability to pass integers to the "safe" option, which previously only accepted booleans. Added "fsync" option. | |
MongoCollection::insert | "safe" 选项接受 integer 值,之前只接受 boolean 值。 增加 "fsync" 选项。 如果设置了 "safe" 选项,返回类型改成包含错误信息的 array。 否则,和之前一样返回 boolean。 | |
MongoCollection::remove | 添加了 "safe" 选项对 integer 的支持,之前只接受 boolean 值。 添加了 "fsync" 选项。 当使用了 "safe" 选项时将会返回包含错误信息的数组。 否则和之前一样返回一个 boolean。 | |
MongoCollection::save | 选项 "safe" 接受 integer 的值,之前仅仅接受 boolean。 增加 "fsync" 选项。 | |
MongoCollection::update | Added 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.7 | MongoCollection::count | 添加了 limit 和 skip 参数。 |
1.0.5 | MongoCollection::batchInsert | Added options parameter. |
MongoCollection::ensureIndex | Added the "name" option to override index name creation. | |
MongoCollection::insert | 修改第二个参数为选项数组。在 1.0.5 之前,第二个参数是 boolean,指示 "safe" 选项。 | |
MongoCollection::remove | 修改第二个参数为选项的 array。在 1.0.5 之前,第二个选项是 boolean 值, 代表了 "safe" 选项。 | |
MongoCollection::save | 增加 options 参数。 | |
MongoCollection::update | Added "safe" option. | |
1.0.2 | MongoClient::__construct | 修改构造器支持选修数组。在 1.0.2 之前,构造器接受以下参数: server 服务器名。 connect 可选的 boolean 参数指定了构造器是否应该在返回前连接到数据库。默认为 TRUE。 persistent 连接是否应该是持久的。 paired 连接是否应该为 paired 模式。 |
MongoCollection::ensureIndex | Changed options parameter from boolean to array. Pre-1.0.2, the second parameter was an optional boolean value specifying a unique index. | |
1.0.1 | MongoCollection::insert | 如果设置了 "safe" 选项并且插入失败了,将会抛出 MongoCursorException。 |
MongoCollection::update | Changed options parameter from boolean to array. Pre-1.0.1, the second parameter was an optional boolean value specifying an upsert. |