I received this error message:
Deprecated: Function Mongo::setSlaveOkay() is deprecated
In the PHP manual, it says:
MongoCollection::setSlaveOkay
(PECL mongo >=1.1.0)
MongoCollection::setSlaveOkay — Change slaveOkay setting for this collection
I couldn't find anything mentioned about it being deprecated.
My PHP version is 5.3.10 and MongoDB version is 1.3.5.
As the other answers state setSlaveOkay has been deprecated in favour of full read preferences ( http://derickrethans.nl/readpreferences.html ). This was a change made when the MongoClient class was introduced ( http://derickrethans.nl/mongoclient.html ).
If you look towards the bottom of the PHP manual page ( http://www.php.net/manual/en/mongocollection.setslaveokay.php ) you will see a changelog section whereby it mentions:
Emits E_DEPRECATED when used.
The "See Also" section below that one provides links to what replaces it, read preferences.
As backup Hannes ( https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/CAWuND9niLo ), one of the maintainers, mentions:
We wanted to prepare people that the preferred way [...] will change in the upcoming 1.3.0 release (scheduled "soon").
So yes, from now on you should be using read preferences.
'slaveOk' has been replaced with the more configurable ReadPreferences capability.
Here is the introduction for PHP ReadReferences:
MongoDB 2.2 and version 1.3.0 of the driver add support for read preferences, which allow control over how queries are directed to mongod instances in a replica set environment. Read preferences may be specified on either a per-connection, per-database, or per-collection basis. Preferences defined at a higher level will be inherited by default (e.g. MongoCollection will inherit read perferences defined on the corresponding MongoDB instance).
Read preferences are specified with a combination of modes and tag sets. Modes determine how mongod instances are prioritized, while tag sets specify criteria for eligible mongod instances.
http://php.net/manual/en/mongo.readpreferences.php
HTH - Rob
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With