Mongo.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. */
  15. if (class_exists('Mongo', false)) {
  16. return;
  17. }
  18. /**
  19. * The connection point between MongoDB and PHP.
  20. * This class is used to initiate a connection and for database server commands.
  21. * @link http://www.php.net/manual/en/class.mongo.php
  22. * @deprecated This class has been DEPRECATED as of version 1.3.0.
  23. * Relying on this feature is highly discouraged. Please use MongoClient instead.
  24. * @see MongoClient
  25. */
  26. class Mongo extends MongoClient
  27. {
  28. /**
  29. * Dummy constructor to throw an exception
  30. */
  31. public function __construct()
  32. {
  33. $this->notImplemented();
  34. }
  35. /**
  36. * Get pool size for connection pools
  37. *
  38. * @link http://php.net/manual/en/mongo.getpoolsize.php
  39. * @return int Returns the current pool size.
  40. *
  41. * @deprecated This feature has been DEPRECATED as of version 1.2.3. Relying on this feature is highly discouraged. Please use MongoPool::getSize() instead.
  42. */
  43. public function getPoolSize()
  44. {
  45. $this->notImplemented();
  46. }
  47. /**
  48. * Returns the address being used by this for slaveOkay reads
  49. *
  50. * @link http://php.net/manual/en/mongo.getslave.php
  51. * @return bool The address of the secondary this connection is using for
  52. * reads. This returns NULL if this is not connected to a replica set or not yet
  53. * initialized.
  54. */
  55. public function getSlave()
  56. {
  57. $this->notImplemented();
  58. }
  59. /**
  60. * Get slaveOkay setting for this connection
  61. *
  62. * @link http://php.net/manual/en/mongo.getslaveokay.php
  63. * @return bool Returns the value of slaveOkay for this instance.
  64. */
  65. public function getSlaveOkay()
  66. {
  67. $this->notImplemented();
  68. }
  69. /**
  70. * Connects to paired database server
  71. *
  72. * @link http://www.php.net/manual/en/mongo.pairconnect.php
  73. * @throws MongoConnectionException
  74. * @return boolean
  75. *
  76. * @deprecated Pass a string of the form "mongodb://server1,server2" to the constructor instead of using this method.
  77. */
  78. public function pairConnect()
  79. {
  80. $this->notImplemented();
  81. }
  82. /**
  83. * Returns information about all connection pools.
  84. *
  85. * @link http://php.net/manual/en/mongo.pooldebug.php
  86. * @return array
  87. * @deprecated This feature has been DEPRECATED as of version 1.2.3. Relying on this feature is highly discouraged. Please use MongoPool::info() instead.
  88. */
  89. public function poolDebug()
  90. {
  91. $this->notImplemented();
  92. }
  93. /**
  94. * Change slaveOkay setting for this connection
  95. *
  96. * @link http://php.net/manual/en/mongo.setslaveokay.php
  97. * @param bool $ok
  98. * @return bool returns the former value of slaveOkay for this instance.
  99. */
  100. public function setSlaveOkay($ok)
  101. {
  102. $this->notImplemented();
  103. }
  104. /**
  105. * Set the size for future connection pools.
  106. *
  107. * @link http://php.net/manual/en/mongo.setpoolsize.php
  108. * @param $size <p>The max number of connections future pools will be able to create. Negative numbers mean that the pool will spawn an infinite number of connections.</p>
  109. * @return bool Returns the former value of pool size.
  110. * @deprecated Relying on this feature is highly discouraged. Please use MongoPool::setSize() instead.
  111. */
  112. public function setPoolSize($size)
  113. {
  114. $this->notImplemented();
  115. }
  116. /**
  117. * Creates a persistent connection with a database server
  118. *
  119. * @link http://www.php.net/manual/en/mongo.persistconnect.php
  120. * @param string $username A username used to identify the connection.
  121. * @param string $password A password used to identify the connection.
  122. * @throws MongoConnectionException
  123. * @return boolean If the connection was successful.
  124. * @deprecated Pass array("persist" => $id) to the constructor instead of using this method.
  125. */
  126. public function persistConnect($username = "", $password = "")
  127. {
  128. $this->notImplemented();
  129. }
  130. /**
  131. * Creates a persistent connection with paired database servers
  132. *
  133. * @link http://www.php.net/manual/en/mongo.pairpersistconnect.php
  134. * @param string $username A username used to identify the connection.
  135. * @param string $password A password used to identify the connection.
  136. * @throws MongoConnectionException
  137. * @return boolean If the connection was successful.
  138. * @deprecated Pass "mongodb://server1,server2" and array("persist" => $id) to the constructor instead of using this method.
  139. */
  140. public function pairPersistConnect($username = "", $password = "")
  141. {
  142. $this->notImplemented();
  143. }
  144. /**
  145. * Connects with a database server
  146. *
  147. * @link http://www.php.net/manual/en/mongo.connectutil.php
  148. * @throws MongoConnectionException
  149. * @return boolean If the connection was successful.
  150. */
  151. protected function connectUtil()
  152. {
  153. $this->notImplemented();
  154. }
  155. /**
  156. * Check if there was an error on the most recent db operation performed
  157. *
  158. * @link http://www.php.net/manual/en/mongo.lasterror.php
  159. * @return array|null Returns the error, if there was one, or NULL.
  160. * @deprecated Use MongoDB::lastError() instead.
  161. */
  162. public function lastError()
  163. {
  164. $this->notImplemented();
  165. }
  166. /**
  167. * Checks for the last error thrown during a database operation
  168. *
  169. * @link http://www.php.net/manual/en/mongo.preverror.php
  170. * @return array Returns the error and the number of operations ago it occurred.
  171. * @deprecated Use MongoDB::prevError() instead.
  172. */
  173. public function prevError()
  174. {
  175. $this->notImplemented();
  176. }
  177. /**
  178. * Clears any flagged errors on the connection
  179. *
  180. * @link http://www.php.net/manual/en/mongo.reseterror.php
  181. * @return array Returns the database response.
  182. * @deprecated Use MongoDB::resetError() instead.
  183. */
  184. public function resetError()
  185. {
  186. $this->notImplemented();
  187. }
  188. /**
  189. * Choose a new secondary for slaveOkay reads
  190. *
  191. * @link www.php.net/manual/en/mongo.switchslave.php
  192. * @return string The address of the secondary this connection is using for reads. This may be the same as the previous address as addresses are randomly chosen. It may return only one address if only one secondary (or only the primary) is available.
  193. * @throws MongoException (error code 15) if it is called on a non-replica-set connection. It will also throw MongoExceptions if it cannot find anyone (primary or secondary) to read from (error code 16).
  194. */
  195. public function switchSlave()
  196. {
  197. $this->notImplemented();
  198. }
  199. /**
  200. * Creates a database error on the database.
  201. *
  202. * @link http://www.php.net/manual/en/mongo.forceerror.php
  203. * @return boolean The database response.
  204. * @deprecated Use MongoDB::forceError() instead.
  205. */
  206. public function forceError()
  207. {
  208. $this->notImplemented();
  209. }
  210. protected function notImplemented()
  211. {
  212. throw new \Exception('The Mongo class is deprecated and not supported through mongo-php-adapter');
  213. }
  214. }