PageRenderTime 29ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/runtime/ext_zend_compat/mongo/ext_mongo.php

http://github.com/facebook/hiphop-php
PHP | 1451 lines | 511 code | 192 blank | 748 comment | 0 complexity | b4e9063609731f8d212e4612435aaba4 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  1. <?hh
  2. // generated by idl-to-hni.php
  3. /* A connection manager for PHP and MongoDB. This class is used to create and
  4. * manage connections. A typical use is: Example #1 MongoClient basic usage
  5. * See MongoClient::__construct() and the section on connecting for more
  6. * information about creating connections.
  7. */
  8. <<__NativeData("ZendCompat")>>
  9. class MongoClient {
  10. public bool $connected = false;
  11. public mixed $status;
  12. protected mixed $server;
  13. protected mixed $persistent;
  14. /* The MongoClient::close() method forcefully closes a connection to the
  15. * database, even if persistent connections are being used. You should never
  16. * have to do this under normal circumstances.
  17. */
  18. <<__Native("ZendCompat")>>
  19. public function close(mixed $connection): mixed;
  20. <<__Native("ZendCompat")>>
  21. public function connect(): mixed;
  22. /* If no parameters are passed, this connects to "localhost:27017" (or
  23. * whatever was specified in php.ini for mongo.default_host and
  24. * mongo.default_port). server should have the form: The connection string
  25. * always starts with mongodb://, to indicate it is a connection string in
  26. * this form. username and password are specified, the constructor will
  27. * attempt to authenticate the connection with the database before returning.
  28. * Username and password are optional and must be followed by an @, if
  29. * specified. At least one host must be given (port optional, always
  30. * defaulting to 27017) and as many hosts as desired may be connected to. Host
  31. * names are comma-separated and the constructor will return successfully if
  32. * it connected to at least one host. If it could not connect to any of the
  33. * hosts, it will throw a MongoConnectionException. Please see the Replica
  34. * Sets section for information on how to connect to Replica Sets. If you
  35. * specified a username and password, you may specify a database to
  36. * authenticate with. If db is not specified, "admin" will be used. An
  37. * optional query string may be used to specify extra options. The same
  38. * options are supported through the options array as well, and are therefore
  39. * redescribed there. See the examples below on how to set those options. One
  40. * part of the options governs how the driver reads from secondary nodes in a
  41. * replica set environment. Extra information on how these read preferences
  42. * work is available as well through the read preferences documentation page.
  43. */
  44. <<__Native("ZendCompat")>>
  45. public function __construct(mixed $server,
  46. mixed $options);
  47. <<__Native("ZendCompat")>>
  48. public function dropDB(mixed $db): mixed;
  49. /* This is the cleanest way of getting a database. If the database name has
  50. * any special characters, MongoClient::selectDB() will need to be used;
  51. * however, this should be sufficient for most cases.
  52. */
  53. <<__Native("ZendCompat")>>
  54. public function __get(mixed $dbname): mixed;
  55. /* Returns an array of all open connections, and information about each of the
  56. * servers
  57. */
  58. <<__Native("ZendCompat")>>
  59. public static function getConnections(): mixed;
  60. /* This method is only useful with a connection to a replica set. It returns
  61. * the status of all of the hosts in the set. Without a replica set, it will
  62. * just return an array with one element containing the host that you are
  63. * connected to. See the query section of this manual for information on
  64. * distributing reads to secondaries.
  65. */
  66. <<__Native("ZendCompat")>>
  67. public function getHosts(): mixed;
  68. <<__Native("ZendCompat")>>
  69. public function getReadPreference(): mixed;
  70. <<__Native("ZendCompat")>>
  71. public function listDBs(): mixed;
  72. <<__Native("ZendCompat")>>
  73. public function selectCollection(mixed $db,
  74. mixed $collection): mixed;
  75. <<__Native("ZendCompat")>>
  76. public function selectDB(mixed $name): mixed;
  77. <<__Native("ZendCompat")>>
  78. public function setReadPreference(mixed $read_preference,
  79. mixed $tags): mixed;
  80. <<__Native("ZendCompat")>>
  81. public function __toString(): mixed;
  82. }
  83. /* Instances of this class are used to interact with a database. To get a
  84. * database: Example #1 Selecting a database Database names can use almost
  85. * any character in the ASCII range. However, they cannot contain " ", "." or
  86. * be the empty string. The name "system" is also reserved. A few unusual,
  87. * but valid, database names: "null", "[x,y]", "3", "\"", "/". Unlike
  88. * collection names, database names may contain "$".
  89. */
  90. <<__NativeData("ZendCompat")>>
  91. class MongoDB {
  92. public int $w = 1;
  93. public int $wtimeout = 10000;
  94. /* This method causes its connection to be authenticated. If authentication is
  95. * enabled for the database server (it's not, by default), you need to log in
  96. * before the database will allow you to do anything. In general, you should
  97. * use the authenticate built into MongoClient::__construct() in preference to
  98. * this method. If you authenticate on connection and the connection drops and
  99. * reconnects during your session, you'll be reauthenticated. If you manually
  100. * authenticated using this method and the connection drops, you'll have to
  101. * call this method again once you're reconnected. This method is identical
  102. * to running: Once a connection has been authenticated, it can only be
  103. * un-authenticated by using the "logout" database command:
  104. */
  105. <<__Native("ZendCompat")>>
  106. public function authenticate(mixed $username,
  107. mixed $password): mixed;
  108. /* Almost everything that is not a CRUD operation can be done with a database
  109. * command. Need to know the database version? There's a command for that.
  110. * Need to do aggregation? There's a command for that. Need to turn up
  111. * logging? You get the idea. This method is identical to:
  112. */
  113. <<__Native("ZendCompat")>>
  114. public function command(mixed $command,
  115. mixed $options): mixed;
  116. /* This method is not meant to be called directly. The preferred way to create
  117. * an instance of MongoDB is through MongoClient::__get() or
  118. * MongoClient::selectDB(). If you're ignoring the previous paragraph and
  119. * want to call it directly you can do so: But don't. Isn't this much
  120. * nicer:
  121. */
  122. <<__Native("ZendCompat")>>
  123. public function __construct(mixed $conn,
  124. mixed $name);
  125. /* This method is used to create capped collections and other collections
  126. * requiring special options. It is identical to running: See
  127. * MongoDB::command() for more information about database commands.
  128. */
  129. <<__Native("ZendCompat")>>
  130. public function createCollection(mixed $name,
  131. mixed $options,
  132. mixed $capped,
  133. mixed $size,
  134. mixed $max): mixed;
  135. /* This method is a flexible interface for creating database references (see
  136. * MongoDBRef).
  137. */
  138. <<__Native("ZendCompat")>>
  139. public function createDBRef(mixed $collection,
  140. mixed $document_or_id): mixed;
  141. /* This drops the database currently being used. This is identical to
  142. * running:
  143. */
  144. <<__Native("ZendCompat")>>
  145. public function drop(): mixed;
  146. <<__Native("ZendCompat")>>
  147. public function dropCollection(mixed $coll): mixed;
  148. /* The Mongo database server runs a JavaScript engine. This method allows you
  149. * to run arbitrary JavaScript on the database. This can be useful if you want
  150. * touch a number of collections lightly, or process some results on the
  151. * database side to reduce the amount that has to be sent to the client.
  152. * Running JavaScript in the database takes a write lock, meaning it blocks
  153. * other operations. Make sure you consider this before running a long script.
  154. * This is a wrapper for a database command. This method is basically:
  155. * MongoDB implies a return statement if you have a single statement on a
  156. * single line. This can cause some unintuitive behavior. For example, this
  157. * returns "foo": However, these return NULL: To avoid surprising
  158. * behavior, it is best not to depend on MongoDB to decide what to return, but
  159. * to explicitly state a return value. In the examples above, we can change
  160. * them to: Now the first statement will return "foo" and the second
  161. * statement will return a count of the "foo" collection.
  162. */
  163. <<__Native("ZendCompat")>>
  164. public function execute(mixed $code,
  165. mixed $args): mixed;
  166. /* This method is not very useful for normal MongoDB use. It forces a database
  167. * error to occur. This means that MongoDB::lastError() will return a generic
  168. * database error after running this command. This command is identical to
  169. * running:
  170. */
  171. <<__Native("ZendCompat")>>
  172. public function forceError(): mixed;
  173. /* This is the easiest way of getting a collection from a database object. If
  174. * a collection name contains strange characters, you may have to use
  175. * MongoDB::selectCollection() instead.
  176. */
  177. <<__Native("ZendCompat")>>
  178. public function __get(mixed $name): mixed;
  179. /* Returns an array of all the collection names for the given database.
  180. */
  181. <<__Native("ZendCompat")>>
  182. public function getCollectionNames(mixed $includeSystemCollections): mixed;
  183. <<__Native("ZendCompat")>>
  184. public function getDBRef(mixed $ref): mixed;
  185. <<__Native("ZendCompat")>>
  186. public function getGridFS(mixed $prefix): mixed;
  187. /* This returns the current database profiling level. The database profiler
  188. * tracks query execution times. If you turn it on (say, using
  189. * MongoDB::setProfilingLevel() or the shell), you can see how many queries
  190. * took longer than a given number of milliseconds or the timing for all
  191. * queries. Note that profiling slows down queries, so it is better to use in
  192. * development or testing than in a time-sensitive application. This function
  193. * is equivalent to running:
  194. */
  195. <<__Native("ZendCompat")>>
  196. public function getProfilingLevel(): mixed;
  197. <<__Native("ZendCompat")>>
  198. public function getReadPreference(): mixed;
  199. /* See the query section of this manual for information on distributing reads
  200. * to secondaries.
  201. */
  202. <<__Native("ZendCompat")>>
  203. public function getSlaveOkay(): mixed;
  204. /* This method is equivalent to:
  205. */
  206. <<__Native("ZendCompat")>>
  207. public function lastError(): mixed;
  208. /* Gets a list of all the collections in the database and returns them as an
  209. * array of MongoCollection objects.
  210. */
  211. <<__Native("ZendCompat")>>
  212. public function listCollections(mixed $includeSystemCollections): mixed;
  213. /* MongoDB::lastError() is usually preferred to this. This method returns the
  214. * last database error that occurred and how many operations ago it occurred.
  215. * It is mostly deprecated.
  216. */
  217. <<__Native("ZendCompat")>>
  218. public function prevError(): mixed;
  219. /* This creates a fresh copy of all database data. It will remove any corrupt
  220. * data and compact and large stretches of free space it finds. This is a very
  221. * slow operation on a large database. This is usually run from the shell or
  222. * the command line, not the driver. It is equivalent to the function:
  223. */
  224. <<__Native("ZendCompat")>>
  225. public function repair(mixed $preserve_cloned_files,
  226. mixed $backup_original_files): mixed;
  227. /* This method is not used in normal operations. It resets the database error
  228. * tracker (which can be incremented with MongoDB::forceError(), also not
  229. * normally used). It is equivalent to running:
  230. */
  231. <<__Native("ZendCompat")>>
  232. public function resetError(): mixed;
  233. <<__Native("ZendCompat")>>
  234. public function selectCollection(mixed $name): mixed;
  235. /* This changes the current database profiling level. This function is
  236. * equivalent to running: The options for level are 0 (off), 1 (queries >
  237. * 100ms), and 2 (all queries). If you would like to profile queries that take
  238. * longer than another time period, use the database command and pass it a
  239. * second option, the number of milliseconds. For example, to profile all
  240. * queries that take longer than one second, run: Profiled queries will
  241. * appear in the system.profile collection of this database.
  242. */
  243. <<__Native("ZendCompat")>>
  244. public function setProfilingLevel(mixed $level): mixed;
  245. <<__Native("ZendCompat")>>
  246. public function setReadPreference(mixed $read_preference,
  247. mixed $tags): mixed;
  248. /* See the query section of this manual for information on distributing reads
  249. * to secondaries.
  250. */
  251. <<__Native("ZendCompat")>>
  252. public function setSlaveOkay(mixed $ok): mixed;
  253. <<__Native("ZendCompat")>>
  254. public function __toString(): mixed;
  255. }
  256. /* Representations a database collection. Collection names can use any
  257. * character in the ASCII set. Some valid collection names are "", "...", "my
  258. * collection", and "*&#@". User-defined collection names cannot contain the
  259. * $ symbol. There are certain system collections which use a $ in their names
  260. * (e.g., local.oplog.$main), but it is a reserved character. If you attempt
  261. * to create and use a collection with a $ in the name, MongoDB will assert.
  262. */
  263. <<__NativeData("ZendCompat")>>
  264. class MongoCollection {
  265. public int $w = 1;
  266. public int $wtimeout = 10000;
  267. /* The MongoDB aggregation framework provides a means to calculate aggregated
  268. * values without having to use MapReduce. While MapReduce is powerful, it is
  269. * often more difficult than necessary for many simple aggregation tasks, such
  270. * as totaling or averaging field values. This method accepts either a
  271. * variable amount of pipeline operators, or a single array of operators
  272. * constituting the pipeline.
  273. */
  274. <<__Native("ZendCompat")>>
  275. public function aggregate(mixed $pipeline,
  276. mixed $op): mixed;
  277. <<__Native("ZendCompat")>>
  278. public function batchInsert(mixed $a,
  279. mixed $options = array()): mixed;
  280. <<__Native("ZendCompat")>>
  281. public function __construct(mixed $db,
  282. mixed $name);
  283. <<__Native("ZendCompat")>>
  284. public function count(mixed $query,
  285. mixed $limit,
  286. mixed $skip): mixed;
  287. <<__Native("ZendCompat")>>
  288. public function createDBRef(mixed $document_or_id): mixed;
  289. /* This method is identical to: Each index, when created, is given a unique
  290. * name. This is generally user-set (with MongoCollection::ensureIndex()'s
  291. * "name" option) or generated by the driver from a combination of key names
  292. * and directions. This name is then used by MongoCollection::deleteIndex() to
  293. * remove the function. Unfortunately, the MongoCollection::ensureIndex()
  294. * generates slightly different names than the shell and, due to backwards
  295. * compatibility issues, MongoCollection::deleteIndex() cannot delete
  296. * custom-named indexes as well. Thus, the best way to delete indexes created
  297. * in the shell or with custom names is to directly call the deleteIndexes
  298. * database command. Thus, if you named an index "superfast query", you could
  299. * only delete it with the PHP driver by running: To find what an index is
  300. * named, you can query the system.indexes collection of a database and look
  301. * for the name field.
  302. */
  303. <<__Native("ZendCompat")>>
  304. public function deleteIndex(mixed $keys): mixed;
  305. <<__Native("ZendCompat")>>
  306. public function deleteIndexes(): mixed;
  307. /* The distinct command returns a list of distinct values for the given key
  308. * across a collection.
  309. */
  310. <<__Native("ZendCompat")>>
  311. public function distinct(mixed $key,
  312. mixed $query): mixed;
  313. /* Drops this collection and deletes its indices.
  314. */
  315. <<__Native("ZendCompat")>>
  316. public function drop(): mixed;
  317. /* This method creates an index on the collection and the specified fields.
  318. * The key specification can either be just a single field name as string, or
  319. * an array containing one or more field names with their sort direction.
  320. */
  321. <<__Native("ZendCompat")>>
  322. public function ensureIndex(mixed $keys,
  323. mixed $options): mixed;
  324. <<__Native("ZendCompat")>>
  325. public function find(mixed $query,
  326. mixed $fields): mixed;
  327. /* The findAndModify command atomically modifies and returns a single
  328. * document. By default, the returned document does not include the
  329. * modifications made on the update. To return the document with the
  330. * modifications made on the update, use the new option.
  331. */
  332. <<__Native("ZendCompat")>>
  333. public function findAndModify(mixed $query,
  334. mixed $update,
  335. mixed $fields,
  336. mixed $options): mixed;
  337. /* As opposed to MongoCollection::find(), this method will return only the
  338. * first result from the result set, and not a MongoCursor that can be
  339. * iterated over.
  340. */
  341. <<__Native("ZendCompat")>>
  342. public function findOne(mixed $query,
  343. mixed $fields): mixed;
  344. /* A concise syntax for getting a collection with a dot-separated name. If a
  345. * collection name contains strange characters, you may have to use
  346. * MongoDB::selectCollection() instead.
  347. */
  348. <<__Native("ZendCompat")>>
  349. public function __get(mixed $name): mixed;
  350. <<__Native("ZendCompat")>>
  351. public function getDBRef(mixed $ref): mixed;
  352. <<__Native("ZendCompat")>>
  353. public function getIndexInfo(): mixed;
  354. <<__Native("ZendCompat")>>
  355. public function getName(): mixed;
  356. <<__Native("ZendCompat")>>
  357. public function getReadPreference(): mixed;
  358. /* See the query section of this manual for information on distributing reads
  359. * to secondaries.
  360. */
  361. <<__Native("ZendCompat")>>
  362. public function getSlaveOkay(): mixed;
  363. <<__Native("ZendCompat")>>
  364. public function group(mixed $keys,
  365. mixed $initial,
  366. mixed $reduce,
  367. mixed $options): mixed;
  368. /* All strings sent to the database must be UTF-8. If a string is not UTF-8, a
  369. * MongoException will be thrown. To insert (or query for) a non-UTF-8 string,
  370. * use MongoBinData.
  371. */
  372. <<__Native("ZendCompat")>>
  373. public function insert(mixed $a,
  374. mixed $options): mixed;
  375. <<__Native("ZendCompat")>>
  376. public function remove(mixed $criteria,
  377. mixed $options): mixed;
  378. /* If the object is from the database, update the existing database object,
  379. * otherwise insert this object.
  380. */
  381. <<__Native("ZendCompat")>>
  382. public function save(mixed $a,
  383. mixed $options): mixed;
  384. <<__Native("ZendCompat")>>
  385. public function setReadPreference(mixed $read_preference,
  386. mixed $tags): mixed;
  387. /* See the query section of this manual for information on distributing reads
  388. * to secondaries.
  389. */
  390. <<__Native("ZendCompat")>>
  391. public function setSlaveOkay(mixed $ok): mixed;
  392. <<__Native("ZendCompat")>>
  393. protected static function toIndexString(mixed $keys): mixed;
  394. <<__Native("ZendCompat")>>
  395. public function __toString(): mixed;
  396. <<__Native("ZendCompat")>>
  397. public function update(mixed $criteria,
  398. mixed $new_object,
  399. mixed $options): mixed;
  400. <<__Native("ZendCompat")>>
  401. public function validate(mixed $scan_data): mixed;
  402. }
  403. /* A cursor is used to iterate through the results of a database query. For
  404. * example, to query the database and see all results, you could do: Example
  405. * #1 MongoCursor basic usage You don't generally create cursors using the
  406. * MongoCursor constructor, you get a new cursor by calling
  407. * MongoCollection::find() (as shown above). Suppose that, in the example
  408. * above, $collection was a 50GB collection. We certainly wouldn't want to
  409. * load that into memory all at once, which is what a cursor is for: allowing
  410. * the client to access the collection in dribs and drabs. If we have a large
  411. * result set, we can iterate through it, loading a few megabytes of results
  412. * into memory at a time. For example, we could do: Example #2 Iterating over
  413. * MongoCursor This will go through each document in the collection, loading
  414. * and garbage collecting documents as needed. Note that this means that a
  415. * cursor does not "contain" the database results, it just manages them. Thus,
  416. * if you print a cursor (with, say, var_dump() or print_r()), you'll just get
  417. * the cursor object, not your documents. To get the documents themselves, you
  418. * can use one of the methods shown above.
  419. */
  420. <<__NativeData("ZendCompat")>>
  421. class MongoCursor {
  422. public static bool $slaveOkay = false;
  423. public static int $timeout = 30000;
  424. /* This is an advanced function and should not be used unless you know what
  425. * you're doing. A query can optionally be nested in a "query" field if other
  426. * options, such as a sort or hint, are given. For instance, adding a sort
  427. * causes the query to become a subfield of a bigger query object, like:
  428. * This method is for adding a top-level field to a query. It makes the query
  429. * a subobject (if it isn't already) and adds the key/value pair of your
  430. * choosing to the top level. Warning It cannot be used to add extra criteria
  431. * to a query on the fly. For instance, this will not work: This does not
  432. * query for a user named "joe" with an age of 20.
  433. */
  434. <<__Native("ZendCompat")>>
  435. public function addOption(mixed $key,
  436. mixed $value): mixed;
  437. /* This method is to be used with tailable cursors. If we are at the end of
  438. * the data, block for a while rather than returning no data. After a timeout
  439. * period, we do return as normal.
  440. */
  441. <<__Native("ZendCompat")>>
  442. public function awaitData(mixed $wait): mixed;
  443. /* A cursor typically fetches a batch of result objects and store them
  444. * locally. This method sets the batchSize value to configure the amount of
  445. * documents retrieved from the server in one data packet. However, it will
  446. * never return more documents than fit in the max batch size limit (usually
  447. * 4MB).
  448. */
  449. <<__Native("ZendCompat")>>
  450. public function batchSize(mixed $batchSize): mixed;
  451. <<__Native("ZendCompat")>>
  452. public function __construct(mixed $connection,
  453. mixed $ns,
  454. mixed $query,
  455. mixed $fields);
  456. /* This method does not affect the state of the cursor: if you haven't queried
  457. * yet, you can still apply limits, skips, etc. If you have started iterating
  458. * through results, it will not move the current position of the cursor. If
  459. * you have exhasted the cursor, it will not reset it.
  460. */
  461. <<__Native("ZendCompat")>>
  462. public function count(mixed $foundOnly): mixed;
  463. /* This returns NULL until MongoCursor::next() is called.
  464. */
  465. <<__Native("ZendCompat")>>
  466. public function current(): mixed;
  467. /* The database sends responses in batches of documents, up to 4MB of
  468. * documents per response. This method checks if the database has more batches
  469. * or if the result set has been exhausted. A cursor being "dead" does not
  470. * mean that MongoCursor::hasNext() will return FALSE, it only means that the
  471. * database is done sending results to the client. The client should continue
  472. * iterating through results until MongoCursor::hasNext() is FALSE.
  473. */
  474. <<__Native("ZendCompat")>>
  475. public function dead(): mixed;
  476. <<__Native("ZendCompat")>>
  477. public function doQuery(): mixed;
  478. <<__Native("ZendCompat")>>
  479. public function explain(): mixed;
  480. /* Fields are specified by "fieldname" : bool. TRUE indicates that a field
  481. * should be returned, FALSE indicates that it should not be returned. You can
  482. * also use 1 and 0 instead of TRUE and FALSE. Thus, to return only the
  483. * "summary" field, one could say: To return all fields except the "hidden"
  484. * field:
  485. */
  486. <<__Native("ZendCompat")>>
  487. public function fields(mixed $f): mixed;
  488. /* This is identical to the function:
  489. */
  490. <<__Native("ZendCompat")>>
  491. public function getNext(): mixed;
  492. <<__Native("ZendCompat")>>
  493. public function getReadPreference(): mixed;
  494. <<__Native("ZendCompat")>>
  495. public function hasNext(): mixed;
  496. <<__Native("ZendCompat")>>
  497. public function hint(mixed $index): mixed;
  498. /* After remaining idle on the server for some amount of time, cursors, by
  499. * default, "die." This is generally the behavior one wants. The database
  500. * cleans up a cursor once all of its results have been sent to the client,
  501. * but if the client doesn't request all of the results, the cursor will
  502. * languish there, taking up resources. Thus, after a few minutes, the cursor
  503. * "times out" and the database assumes the client has gotten everything it
  504. * needs and cleans up its the cursor's resources. If, for some reason, you
  505. * need a cursor to hang around for a long time, you can prevent the database
  506. * from cleaning it up by using this method. However, if you make a cursor
  507. * immortal, you need to iterate through all of its results (or at least until
  508. * MongoCursor::dead() returns TRUE) or the cursor will hang around the
  509. * database forever, taking up resources.
  510. */
  511. <<__Native("ZendCompat")>>
  512. public function immortal(mixed $liveForever): mixed;
  513. /* This can be called before or after the query.
  514. */
  515. <<__Native("ZendCompat")>>
  516. public function info(): mixed;
  517. <<__Native("ZendCompat")>>
  518. public function key(): mixed;
  519. <<__Native("ZendCompat")>>
  520. public function limit(mixed $num): mixed;
  521. <<__Native("ZendCompat")>>
  522. public function next(): mixed;
  523. /* This option allows mongos to send partial query results if a shard is
  524. * unreachable. This is only applicable when running a sharded MongoDB cluster
  525. * and connecting to a mongos. If a shard goes down and a query needs to be
  526. * sent to that shard, mongos will return the results (if any) from shards it
  527. * already contacted, then an error message that it could not reach the shard
  528. * (a MongoCursorException in PHP). If you would like to get whatever results
  529. * mongos can provide and no exception, you can use this method. Note that
  530. * this means that you won't have an indication that a shard is down in your
  531. * query response. This has no effect on the query if all shards are
  532. * reachable. This flag was implemented in MongoDB version 1.7.5, so will only
  533. * work with that version and higher.
  534. */
  535. <<__Native("ZendCompat")>>
  536. public function partial(mixed $okay): mixed;
  537. <<__Native("ZendCompat")>>
  538. public function reset(): mixed;
  539. /* This is identical to the function:
  540. */
  541. <<__Native("ZendCompat")>>
  542. public function rewind(): mixed;
  543. /* The MongoCursor class has several methods for setting flags on the query
  544. * object. This method is available in case the MongoDB wire protocol has
  545. * acquired a new flag, and the driver has not been updated with a method for
  546. * this new flag. In all other cases, the method should be used. See the "See
  547. * also" section for available methods.
  548. */
  549. <<__Native("ZendCompat")>>
  550. public function setFlag(mixed $flag,
  551. mixed $set): mixed;
  552. <<__Native("ZendCompat")>>
  553. public function setReadPreference(mixed $read_preference,
  554. mixed $tags): mixed;
  555. <<__Native("ZendCompat")>>
  556. public function skip(mixed $num): mixed;
  557. /* Calling this will make the driver route reads to secondaries if: You are
  558. * using a replica set and You created a MongoClient instance using the option
  559. * "replicaSet" => "setName" and There is a healthy secondary that can be
  560. * reached by the driver. You can check which server was used for this query
  561. * by calling MongoCursor::info() after running the query. It's server field
  562. * will show which server the query was sent to. Note that you should use
  563. * this function even if you do not use the automatic routing to secondaries.
  564. * If you connect directly to a secondary in a replica set, you still need to
  565. * call this function, which basically tells the database that you are aware
  566. * that you might be getting older data and you're okay with that. If you do
  567. * not call this, you'll get "not master" errors when you try to query. This
  568. * method will override the static class variable MongoCursor::$slaveOkay. It
  569. * will also override Mongo::setSlaveOkay(), MongoDB::setSlaveOkay() and
  570. * MongoCollection::setSlaveOkay().
  571. */
  572. <<__Native("ZendCompat")>>
  573. public function slaveOkay(mixed $okay): mixed;
  574. /* Use snapshot mode for the query. Snapshot mode assures no duplicates are
  575. * returned, or objects missed, which were present at both the start and end
  576. * of the query's execution (if an object is new during the query, or deleted
  577. * during the query, it may or may not be returned, even with snapshot mode).
  578. * Note that short query responses (less than 1MB) are always effectively
  579. * snapshotted. Currently, snapshot mode may not be used with sorting or
  580. * explicit hints.
  581. */
  582. <<__Native("ZendCompat")>>
  583. public function snapshot(): mixed;
  584. <<__Native("ZendCompat")>>
  585. public function sort(mixed $fields): mixed;
  586. /* Mongo has a feature known as tailable cursors which are similar to the Unix
  587. * "tail -f" command. Tailable means cursor is not closed when the last data
  588. * is retrieved. Rather, the cursor marks the final object's position. you can
  589. * resume using the cursor later, from where it was located, if more data were
  590. * received. Like any "latent cursor", the cursor may become invalid at some
  591. * point -- for example if that final object it references were deleted. Thus,
  592. * you should be prepared to requery if the cursor is MongoCursor::dead().
  593. */
  594. <<__Native("ZendCompat")>>
  595. public function tailable(mixed $tail): mixed;
  596. /* A timeout can be set at any time and will affect subsequent queries on the
  597. * cursor, including fetching more results from the database.
  598. */
  599. <<__Native("ZendCompat")>>
  600. public function timeout(mixed $ms): mixed;
  601. <<__Native("ZendCompat")>>
  602. public function valid(): mixed;
  603. }
  604. /* A unique identifier created for database objects. If an object is inserted
  605. * into the database without an _id field, an _id field will be added to it
  606. * with a MongoId instance as its value. If the data has a naturally occuring
  607. * unique field (say, a username or timestamp) it is fine to use this as the
  608. * _id field instead, and it will not be replaced with a MongoId. Instances
  609. * of the MongoId class fulfill the role that autoincrementing does in a
  610. * relational database: to provide a unique key if the data does not natually
  611. * have one. Autoincrementing does not work well with a sharded database, as
  612. * it is impossible to find what the next number should be quickly. This class
  613. * fulfills the constraints of quickly generating a value that is unique
  614. * across shards. Each MongoId is 12 bytes (making its string form 24
  615. * hexidecimal characters). The first four bytes are a timestamp, the next
  616. * three are a hash of the client machine's hostname, the next two are the two
  617. * least significant bytes of the process id running the script, and the last
  618. * three bytes are an incrementing value. MongoIds are
  619. * serializable/unserializable. Their serialized form is similar to their
  620. * string form: C:7:"MongoId":24:{4af9f23d8ead0e1d32000000}
  621. */
  622. <<__NativeData("ZendCompat")>>
  623. class MongoId {
  624. <<__Native("ZendCompat")>>
  625. public function __construct(mixed $id);
  626. /* This returns the hostname MongoId is using to generate unique ids. This
  627. * should be the same value gethostname() returns. It is identical to the
  628. * function:
  629. */
  630. <<__Native("ZendCompat")>>
  631. public static function getHostname(): mixed;
  632. <<__Native("ZendCompat")>>
  633. public function getInc(): mixed;
  634. /* Extracts the pid from the Mongo ID
  635. */
  636. <<__Native("ZendCompat")>>
  637. public function getPID(): mixed;
  638. /* This returns the same thing as running time() when the id is created.
  639. */
  640. <<__Native("ZendCompat")>>
  641. public function getTimestamp(): mixed;
  642. /* This function is only used by PHP internally, it shouldn't need to ever be
  643. * called by the user. It is identical to the function:
  644. */
  645. <<__Native("ZendCompat")>>
  646. public static function __set_state(mixed $props): mixed;
  647. <<__Native("ZendCompat")>>
  648. public function __toString(): mixed;
  649. }
  650. /* Represents JavaScript code for the database. MongoCode objects are
  651. * composed of two parts: a string of code and an optional scope. The string
  652. * of code must be valid JavaScript. The scope is a associative array of
  653. * variable name/value pairs.
  654. */
  655. <<__NativeData("ZendCompat")>>
  656. class MongoCode {
  657. public string $code = '';
  658. public mixed $scope;
  659. <<__Native("ZendCompat")>>
  660. public function __construct(mixed $code,
  661. mixed $scope);
  662. <<__Native("ZendCompat")>>
  663. public function __toString(): mixed;
  664. }
  665. /* Represent date objects for the database. This class should be used to save
  666. * dates to the database and to query for dates. For example: Example #1
  667. * Storing dates with MongoDate MongoDB stores dates as milliseconds past
  668. * the epoch. This means that dates do not contain timezone information.
  669. * Timezones must be stored in a separate field if needed. Second, this means
  670. * that any precision beyond milliseconds will be lost when the document is
  671. * sent to/from the database.
  672. */
  673. <<__NativeData("ZendCompat")>>
  674. class MongoDate {
  675. public int $sec = 0;
  676. public int $usec = 0;
  677. /* Creates a new date. If no parameters are given, the current time is used.
  678. */
  679. <<__Native("ZendCompat")>>
  680. public function __construct(mixed $sec,
  681. mixed $usec);
  682. /* Returns a string representation of this date, similar to the representation
  683. * returned by microtime().
  684. */
  685. <<__Native("ZendCompat")>>
  686. public function __toString(): mixed;
  687. }
  688. /* This class can be used to create regular expressions. Typically, these
  689. * expressions will be used to query the database and find matching strings.
  690. * More unusually, they can be saved to the database and retrieved. Regular
  691. * expressions consist of four parts. First a / as starting delimiter, then
  692. * then pattern, another / and finally a string containing flags. Example #1
  693. * Regular expression pattern /pattern/flags MongoDB recognizes six regular
  694. * expression flags: i: Case insensitive m: Multiline x: Can contain
  695. * comments l: locale s: dotall, "." matches everything, including newlines
  696. * u: match unicode
  697. */
  698. <<__NativeData("ZendCompat")>>
  699. class MongoRegex {
  700. public string $regex = '';
  701. public string $flags = '';
  702. /* Creates a new regular expression.
  703. */
  704. <<__Native("ZendCompat")>>
  705. public function __construct(mixed $regex);
  706. /* Returns a string representation of this regular expression.
  707. */
  708. <<__Native("ZendCompat")>>
  709. public function __toString(): mixed;
  710. }
  711. /* An object that can be used to store or retrieve binary data from the
  712. * database. The maximum size of a single object that can be inserted into
  713. * the database is 16MB. For data that is larger than this (movies, music,
  714. * Henry Kissinger's autobiography), use MongoGridFS. For data that is smaller
  715. * than 16MB, you may find it easier to embed it within the document using
  716. * MongoBinData. For example, to embed an image in a document, one could
  717. * write: This class contains a type field, which currently gives no
  718. * additional functionality in the driver or the database. There are five
  719. * predefined types (which are the class constants listed below), and the user
  720. * can create their own (at the risk of the BSON spec catching up with them).
  721. * By default, the PHP driver always uses type 2: a byte array.
  722. */
  723. <<__NativeData("ZendCompat")>>
  724. class MongoBinData {
  725. public string $bin = '';
  726. public int $type = 0;
  727. /* Creates a new binary data object. There are five types of binary data
  728. * currently recognized by the BSON spec: function (0x01), byte array (0x02),
  729. * UUID (0x03), MD5 (0x05), and user defined (0x80). The default type is byte
  730. * array (0x02). There is no particular difference in how the driver or server
  731. * interpret different types, so by and large they are irrelevant for now. Any
  732. * number (between 0 and 255) could be used for type, if the user is willing
  733. * to assume the risk that the database might eventually do something with
  734. * binary data based on type.
  735. */
  736. <<__Native("ZendCompat")>>
  737. public function __construct(mixed $data,
  738. mixed $type);
  739. <<__Native("ZendCompat")>>
  740. public function __toString(): mixed;
  741. }
  742. /* The class can be used to save 32-bit integers to the database on a 64-bit
  743. * system.
  744. */
  745. <<__NativeData("ZendCompat")>>
  746. class MongoInt32 {
  747. public string $value = '';
  748. /* Creates a new 32-bit number with the given value.
  749. */
  750. <<__Native("ZendCompat")>>
  751. public function __construct(mixed $value);
  752. <<__Native("ZendCompat")>>
  753. public function __toString(): mixed;
  754. }
  755. /* The class can be used to save 64-bit integers to the database on a 32-bit
  756. * system.
  757. */
  758. <<__NativeData("ZendCompat")>>
  759. class MongoInt64 {
  760. public string $value = '';
  761. /* Creates a new 64-bit number with the given value.
  762. */
  763. <<__Native("ZendCompat")>>
  764. public function __construct(mixed $value);
  765. <<__Native("ZendCompat")>>
  766. public function __toString(): mixed;
  767. }
  768. /* This class can be used to create lightweight links between objects in
  769. * different collections. Motivation: Suppose we need to refer to a document
  770. * in another collection. The easiest way is to create a field in the current
  771. * document. For example, if we had a "people" collection and an "addresses"
  772. * collection, we might want to create a link between each person document and
  773. * an address document: Example #1 Linking documents Then, later on, we can
  774. * find the person's address by querying the "addresses" collection with the
  775. * MongoId we saved in the "people" collection. Suppose now that we have a
  776. * more general case, where we don't know which collection (or even which
  777. * database) contains the referenced document. MongoDBRef is a good choice for
  778. * this case, as it is a common format that all of the drivers and the
  779. * database understand. If each person had a list of things they liked which
  780. * could come from multiple collections, such as "hobbies", "sports", "books",
  781. * etc., we could use MongoDBRefs to keep track of what "like" went with what
  782. * collection: Example #2 Creating MongoDBRef links Database references can
  783. * be thought of as hyperlinks: they give the unique address of another
  784. * document, but they do not load it or automatically follow the
  785. * link/reference. A database reference is just a normal associative array,
  786. * not an instance of MongoDBRef, so this class is a little different than the
  787. * other data type classes. This class contains exclusively static methods for
  788. * manipulating database references.
  789. */
  790. <<__NativeData("ZendCompat")>>
  791. class MongoDBRef {
  792. protected static string $refKey = '$ref';
  793. protected static string $idKey = '$id';
  794. /* If no database is given, the current database is used.
  795. */
  796. <<__Native("ZendCompat")>>
  797. public static function create(mixed $collection,
  798. mixed $id,
  799. mixed $database): mixed;
  800. <<__Native("ZendCompat")>>
  801. public static function get(mixed $db,
  802. mixed $ref): mixed;
  803. /* This method does not actually follow the reference, so it does not
  804. * determine if it is broken or not. It merely checks that ref is in valid
  805. * database reference format (in that it is an object or array with $ref and
  806. * $id fields).
  807. */
  808. <<__Native("ZendCompat")>>
  809. public static function isRef(mixed $ref): mixed;
  810. }
  811. /* MongoMinKey is a special type used by the database that evaluates to less
  812. * than any other type. Thus, if a query is sorted by a given field in
  813. * ascending order, any document with a MongoMinKey as its value will be
  814. * returned first. MongoMinKey has no associated fields, methods, or
  815. * constants. It is merely the "smallest" thing that can be inserted into the
  816. * database.
  817. */
  818. <<__NativeData("ZendCompat")>>
  819. class MongoMinKey {
  820. }
  821. /* MongoMaxKey is a special type used by the database that evaluates to
  822. * greater than any other type. Thus, if a query is sorted by a given field in
  823. * ascending order, any document with a MongoMaxKey as its value will be
  824. * returned last. MongoMaxKey has no associated fields, methods, or
  825. * constants. It is merely the "largest" thing that can be inserted into the
  826. * database.
  827. */
  828. <<__NativeData("ZendCompat")>>
  829. class MongoMaxKey {
  830. }
  831. /* MongoTimestamp is used by sharding. If you're not looking to write sharding
  832. * tools, what you probably want is MongoDate. MongoTimestamp is 4 bytes of
  833. * timestamp (seconds since the epoch) and 4 bytes of increment. This class
  834. * is not for measuring time, creating a timestamp on a document or
  835. * automatically adding or updating a timestamp on a document. Unless you are
  836. * writing something that interacts with the sharding internals, stop, go
  837. * directly to MongoDate, do not pass go, do not collect 200 dollars. This is
  838. * not the class you are looking for. If you are writing sharding tools, read
  839. * on.
  840. */
  841. <<__NativeData("ZendCompat")>>
  842. class MongoTimestamp {
  843. public int $sec = 0;
  844. public int $inc = 0;
  845. /* Creates a new timestamp. If no parameters are given, the current time is
  846. * used and the increment is automatically provided. The increment is set to 0
  847. * when the module is loaded and is incremented every time this constructor is
  848. * called (without the $inc parameter passed in).
  849. */
  850. <<__Native("ZendCompat")>>
  851. public function __construct(mixed $sec,
  852. mixed $inc);
  853. /* Returns the "sec" field of this timestamp.
  854. */
  855. <<__Native("ZendCompat")>>
  856. public function __toString(): mixed;
  857. }
  858. /* Utilities for storing and retrieving files from the database. GridFS is a
  859. * storage specification all supported drivers implement. Basically, it
  860. * defines two collections: files, for file metadata, and chunks, for file
  861. * content. If the file is large, it will automatically be split into smaller
  862. * chunks and each chunk will be saved as a document in the chunks collection.
  863. * Each document in the files collection contains the filename, upload date,
  864. * and md5 hash. It also contains a unique _id field, which can be used to
  865. * query the chunks collection for the file's content. Each document in the
  866. * chunks collection contains a chunk of binary data, a files_id field that
  867. * matches its file's _id, and the position of this chunk in the overall file.
  868. * For example, the files document is something like: and the chunks
  869. * documents look like: Of course, the default chunk size is thousands of
  870. * bytes, but that makes an unwieldy example.
  871. */
  872. <<__NativeData("ZendCompat")>>
  873. class MongoGridFS extends MongoCollection {
  874. public mixed $chunks;
  875. protected mixed $filesName;
  876. protected mixed $chunksName;
  877. /* Files as stored across two collections, the first containing file meta
  878. * information, the second containing chunks of the actual file. By default,
  879. * fs.files and fs.chunks are the collection names used. Use one argument to
  880. * specify a prefix other than "fs": $fs = new MongoGridFS($db, "myfiles");
  881. * uses myfiles.files and myfiles.chunks collections.
  882. */
  883. <<__Native("ZendCompat")>>
  884. public function __construct();
  885. <<__Native("ZendCompat")>>
  886. public function delete(mixed $id): mixed;
  887. <<__Native("ZendCompat")>>
  888. public function drop(): mixed;
  889. <<__Native("ZendCompat")>>
  890. public function find(mixed $query,
  891. mixed $fields): mixed;
  892. <<__Native("ZendCompat")>>
  893. public function findOne(mixed $query): mixed;
  894. <<__Native("ZendCompat")>>
  895. public function get(mixed $id): mixed;
  896. <<__Native("ZendCompat")>>
  897. public function put(mixed $filename,
  898. mixed $metadata): mixed;
  899. <<__Native("ZendCompat")>>
  900. public function remove(mixed $query,
  901. mixed $options): mixed;
  902. <<__Native("ZendCompat")>>
  903. public function storeBytes(mixed $bytes,
  904. mixed $metadata,
  905. mixed $options): mixed;
  906. <<__Native("ZendCompat")>>
  907. public function storeFile(mixed $filename,
  908. mixed $metadata,
  909. mixed $options): mixed;
  910. <<__Native("ZendCompat")>>
  911. public function storeUpload(mixed $name,
  912. mixed $metadata): mixed;
  913. }
  914. /* A database file object.
  915. */
  916. <<__NativeData("ZendCompat")>>
  917. class MongoGridFSFile {
  918. public mixed $file;
  919. protected mixed $gridfs;
  920. <<__Native("ZendCompat")>>
  921. public function __construct(mixed $gridfs,
  922. mixed $file);
  923. /* Warning: this will load the file into memory. If the file is bigger than
  924. * your memory, this will cause problems!
  925. */
  926. <<__Native("ZendCompat")>>
  927. public function getBytes(): mixed;
  928. <<__Native("ZendCompat")>>
  929. public function getFilename(): mixed;
  930. /* This method returns a stream resource that can be used with all file
  931. * functions in PHP that deal with reading files. The contents of the file are
  932. * pulled out of MongoDB on the fly, so that the whole file does not have to
  933. * be loaded into memory first. At most two GridFSFile chunks will be loaded
  934. * in memory.
  935. */
  936. <<__Native("ZendCompat")>>
  937. public function getResource(): mixed;
  938. <<__Native("ZendCompat")>>
  939. public function getSize(): mixed;
  940. <<__Native("ZendCompat")>>
  941. public function write(mixed $filename): mixed;
  942. }
  943. /* Cursor for database file results.
  944. */
  945. <<__NativeData("ZendCompat")>>
  946. class MongoGridFSCursor extends MongoCursor {
  947. protected mixed $gridfs;
  948. <<__Native("ZendCompat")>>
  949. public function __construct(mixed $gridfs,
  950. mixed $connection,
  951. mixed $ns,
  952. mixed $query,
  953. mixed $fields);
  954. <<__Native("ZendCompat")>>
  955. public function current(): mixed;
  956. <<__Native("ZendCompat")>>
  957. public function getNext(): mixed;
  958. }
  959. /* Logging can be used to get detailed information about what the driver is
  960. * doing. The logging mechanism as used by MongoLog emits all log messages as
  961. * a PHP notice. Depending on the server interface that you use, that means
  962. * that they will either be sent to strerr (with PHP-CLI), or otherwise to the
  963. * web server's error log. In order for log messages to be output by PHP their
  964. * level (E_NOTICE) does need to be configured to be shown. That means the
  965. * E_NOTICE bit needs to be part of PHP's error_reporting level and that
  966. * display_errors is set to 1. Logging is turned off, by default. This class
  967. * allows you to turn on specific levels of logging for specific parts of the
  968. * driver. Some examples:
  969. */
  970. <<__NativeData("ZendCompat")>>
  971. class MongoLog {
  972. private static int $level = 0;
  973. private static int $module = 0;
  974. private static mixed $callback = 0;
  975. /* Retrieves the callback function name.
  976. */
  977. <<__Native("ZendCompat")>>
  978. public static function getCallback(): mixed;
  979. /* This can be used to see the log level. Use the constants described in the
  980. * MongoLog section with bitwise operators to check the level.
  981. */
  982. <<__Native("ZendCompat")>>
  983. public static function getLevel(): mixed;
  984. /* This function can be used to see which parts of the driver's functionality
  985. * are being logged. Use the constants described in the MongoLog section with
  986. * bitwise operators to check if specific modules are being logged.
  987. */
  988. <<__Native("ZendCompat")>>
  989. public static function getModule(): mixed;
  990. /* This function will set a callback function to be called for MongoLog events
  991. * instead of triggering warnings.
  992. */
  993. <<__Native("ZendCompat")>>
  994. public static function setCallback(mixed $log_function,
  995. mixed $module,
  996. mixed $level): mixed;
  997. /* This function can be used to set how verbose logging should be and the
  998. * types of activities that should be logged. Use the constants described in
  999. * the MongoLog section with bitwise operators to specify levels. Note that
  1000. * you must also call MongoLog::setModule() to choose what part of the driver
  1001. * to log.
  1002. */
  1003. <<__Native("ZendCompat")>>
  1004. public static function setLevel(mixed $level): mixed;
  1005. /* This function can be used to set which parts of the driver's functionality
  1006. * should be logged. Use the constants described in the MongoLog section with
  1007. * bitwise operators to specify modules. Note that you must also call
  1008. * MongoLog::setLevel() to turn on logging.
  1009. */
  1010. <<__Native("ZendCompat")>>
  1011. public static function setModule(mixed $module): mixed;
  1012. }
  1013. /* Warning The current (1.3.0+) releases of the driver no longer implements
  1014. * pooling. This class and its methods are therefore deprecated and should not
  1015. * be used.
  1016. */
  1017. <<__NativeData("ZendCompat")>>
  1018. class MongoPool {
  1019. <<__Native("ZendCompat")>>
  1020. public static function getSize(): mixed;
  1021. /* Returns an array of information about all connection pools.
  1022. */
  1023. <<__Native("ZendCompat")>>
  1024. public static function info(): mixed;
  1025. /* Sets the max number of connections new pools will be able to create.
  1026. */
  1027. <<__Native("ZendCompat")>>
  1028. public static function setSize(mixed $size): mixed;
  1029. }
  1030. /* A connection between PHP and MongoDB. This class extends MongoClient and
  1031. * provides access to several deprecated methods. For backwards
  1032. * compatibility, it also defaults the "w" option of its constructor argument
  1033. * to 0, which does not require write operations to be acknowledged by the
  1034. * server. See MongoClient::__construct() for more information. Warning This
  1035. * class has been DEPRECATED as of version 1.3.0. Relying on this feature is
  1036. * highly discouraged. Please use MongoClient instead.
  1037. */
  1038. <<__NativeData("ZendCompat")>>
  1039. class Mongo extends MongoClient {
  1040. <<__Native("ZendCompat")>>
  1041. public function connectUtil(): mixed;
  1042. /* This method overwrites the MongoClient constructor and turns off
  1043. * acknowledged writes. Please see MongoClient::__construct() for description
  1044. * of the parameters.
  1045. */
  1046. <<__Native("ZendCompat")>>
  1047. public function __construct(mixed $server = null, mixed $options = null);
  1048. <<__Native("ZendCompat")>>
  1049. public static function getPoolSize(): mixed;
  1050. /* This finds the address of the secondary currently being used for reads. It
  1051. * is a read-only method: it does not change anything about the internal state
  1052. * of the object. When you create a connection to the database, the driver
  1053. * will not immediately decide on a secondary to use. Thus, after you connect,
  1054. * this function will return NULL even if there are secondaries available.
  1055. * When you first do a query with slaveOkay set, at that point the driver will
  1056. * choose a secondary for this connection. At that point, this function will
  1057. * return the chosen secondary. See the query section of this manual for
  1058. * information on distributing reads to secondaries.
  1059. */
  1060. <<__Native("ZendCompat")>>
  1061. public function getSlave(): mixed;
  1062. /* See the query section of this manual for information on distributing reads
  1063. * to secondaries.
  1064. */
  1065. <<__Native("ZendCompat")>>
  1066. public function getSlaveOkay(): mixed;
  1067. <<__Native("ZendCompat")>>
  1068. public static function poolDebug(): mixed;
  1069. <<__Native("ZendCompat")>>
  1070. public static function setPoolSize(mixed $size): mixed;
  1071. /* See the query section of this manual for information on distributing reads
  1072. * to secondaries.
  1073. */
  1074. <<__Native("ZendCompat")>>
  1075. public function setSlaveOkay(mixed $ok): mixed;
  1076. /* This choses a random secondary for a connection to read from. It is called
  1077. * automatically by the driver and should not need to be used. It calls
  1078. * MongoClient::getHosts() (to refresh the status of hosts) and
  1079. * Mongo::getSlave() (to get the return value). See the query section of this
  1080. * manual for information on distributing reads to secondaries.
  1081. */
  1082. <<__Native("ZendCompat")>>
  1083. public function switchSlave(): mixed;
  1084. }
  1085. /* Default Mongo exception. This covers a bunch of different error conditions
  1086. * that may eventually be moved to more specific exceptions, but will always
  1087. * extend MongoException. The MongoSomething object has not been correctly
  1088. * initialized by its constructor Code: 0 Probably your Mongo object is not
  1089. * connected to a database server. zero-length keys are not allowed, did you
  1090. * use $ with double quotes? Code: 1 You tried to save "" as a key. You
  1091. * generally should not do this. "" can mess up subobject access and is used
  1092. * by MongoDB internally. However, if you really want, you can set
  1093. * mongo.allow_empty_keys to true in your php.ini file to override this sanity
  1094. * check. If you override this, it is highly recommended that you set error
  1095. * checking to strict to avoid string interpolation errors. '.' not allowed
  1096. * in key: <key> Code: 2 You attempted to write a key with '.' in it, which
  1097. * is prohibited. insert too large: <size>, max: <max> Code: 3 You're
  1098. * attempting to send too much data to the database at once: the database will
  1099. * only accept inserts up to a certain size (currently 16 MB). no elements in
  1100. * doc Code: 4 You're attempting to save a document with no fields. size of
  1101. * BSON doc is <size> bytes, max <max>MB Code: 5 You're attempting to save a
  1102. * document that is larger than MongoDB can save. no documents given Code: 6
  1103. * You're attempting to batch insert an empty array of documents.
  1104. * MongoCollection::group takes an array, object, or MongoCode key Code: 7
  1105. * Wrong type parameter send to MongoCollection::group(). field names must be
  1106. * strings Code: 8 You should format field selectors as array("field1" => 1,
  1107. * "field2" => 1, ..., "fieldN" => 1). invalid regex Code: 9 The regex
  1108. * passed to MongoRegex is not of the correct form. MongoDBRef::get: $ref
  1109. * field must be a string Code: 10 MongoDBRef::get: $db field must be a
  1110. * string Code: 11 non-utf8 string: <str> Code: 12 This error occurs if
  1111. * you attempt to send a non-utf8 string to the database. All strings going
  1112. * into the database should be UTF8. See php.ini options for the transition
  1113. * option of quieting this exception. mutex error: <err> Code: 13 The
  1114. * driver uses mutexes for synchronizing requests and responses in
  1115. * multithreaded environments. This is a fairly serious error and may not have
  1116. * a stack trace. It's unusual and should be reported to maintainers with any
  1117. * system information and steps to reproduce that you can provide. index name
  1118. * too long: <len>, max <max> characters Code: 14 Indexes with names longer
  1119. * than 128 characters cannot be created. If you get this error, you should
  1120. * use MongoCollection::ensureIndex()'s "name" option to create a shorter name
  1121. * for your index.
  1122. */
  1123. <<__NativeData("ZendCompat")>>
  1124. class MongoException extends Exception {
  1125. }
  1126. /* The MongoResultException is thrown by several command helpers (such as
  1127. * MongoCollection::findAndModify()) in the event of failure. The original
  1128. * result document is available through MongoResultException::getDocument().
  1129. */
  1130. <<__NativeData("ZendCompat")>>
  1131. class MongoResultException extends MongoException {
  1132. public mixed $document;
  1133. /* Retrieves the full error result document.
  1134. */
  1135. <<__Native("ZendCompat")>>
  1136. public function getDocument(): mixed;
  1137. }
  1138. /* Caused by accessing a cursor incorrectly or a error receiving a reply. Note
  1139. * that this can be thrown by any database request that receives a reply, not
  1140. * just queries. Writes, commands, and any other operation that sends
  1141. * information to the database and waits for a response can throw a
  1142. * MongoCursorException. The only exception is new MongoClient() (creating a
  1143. * new connection), which will only throw MongoConnectionExceptions. This
  1144. * returns a specific error message to help diagnose the problem and a numeric
  1145. * error code associated with the cause of the exception. For example,
  1146. * suppose you tried to insert two documents with the same _id: This would
  1147. * produce output like: Note that the MongoDB error code (11000) is used for
  1148. * the PHP error code. The PHP driver uses the "native" error code wherever
  1149. * possible. The following is a list of common errors, codes, and causes.
  1150. * Exact errors are in italics, errors where the message can vary are
  1151. * described in obliques. cannot modify cursor after beginning iteration
  1152. * Code: 0 You are calling a method that sets up the query after executing
  1153. * the query. Reset the cursor and try again. An example: Get next batch
  1154. * send errors Code: 1 Could not send the query to the database. Make sure
  1155. * the database is still up and the network is okay. cursor not found Code:
  1156. * 2 The driver was trying to fetch more results from the database, but the
  1157. * database did not have a record of the query. This usually means that the
  1158. * cursor timed out on the server side: after a few minutes of inactivity, the
  1159. * database will kill a cursor (see MongoCursor::immortal() for information on
  1160. * preventing this). An example: cursor->buf.pos is null Code: 3 This
  1161. * may indicate you are out of RAM or some other extraordinary circumstance.
  1162. * couldn't get response header Code: 4 A common error if the database or
  1163. * network goes down. This means that the driver couldn't get a response from
  1164. * the connection. no db response Code: 5 This may not even be an error,
  1165. * for example, the database command "shutdown" returns no response. However,
  1166. * if you were expecting a response, this means the database didn't give one.
  1167. * bad response length: %d, did the db assert? Code: 6 This means that the
  1168. * database said that its response was less than 0. This error probably
  1169. * indicates a network error or database corruption. incomplete header Code:
  1170. * 7 Highly unusual. Occurs if the database response started out correctly,
  1171. * but broke off in the middle. Probably indicates a network problem.
  1172. * incomplete response Code: 8 Highly unusual. Occurs if the database
  1173. * response started out correctly, but broke off in the middle. Probably
  1174. * indicates a network problem. couldn't find a response Code: 9 If the
  1175. * response was cached and now cannot be located. error getting socket Code:
  1176. * 10 The socket was closed or encountered an error. The driver should
  1177. * automatically reconnect (if possible) on the next operation. couldn't find
  1178. * reply, please try again Code: 11 The driver saves any database responses
  1179. * it cannot immediately match with a request. This exception occurs if the
  1180. * driver has already passed your request's response and cannot find your
  1181. * response in its cache. error getting database response: errstr WSA error
  1182. * getting database response: errstr "errstr" is an io error reported
  1183. * directly from the C socket subsystem. On Windows, the error message is
  1184. * prefixed with "WSA". Timeout error Code: 13 If there was an error while
  1185. * waiting for a query to complete. couldn't send query: <various> Code: 14
  1186. * C socket error on send. max number of retries exhausted, couldn't send
  1187. * query Code: 19 The driver will automatically retry "plain" queries (not
  1188. * commands) a couple of times if the first attempt failed for certain
  1189. * reasons. This is to cause fewer exceptions during replica set failover
  1190. * (although you will probably still have to deal with some) and gloss over
  1191. * transient network issues. This can also be caused by the driver not being
  1192. * able to reconnect at all to the database (if, for example, the database is
  1193. * unreachable). Version 1.2.2+.
  1194. */
  1195. <<__NativeData("ZendCompat")>>
  1196. class MongoCursorException extends MongoException {
  1197. private mixed $host;
  1198. private int $fd = 0;
  1199. /* Returns the hostname of the server the query was sent too.
  1200. */
  1201. <<__Native("ZendCompat")>>
  1202. public function getHost(): mixed;
  1203. }
  1204. /* Caused by a query timing out. You can set the length of time to wait before
  1205. * this exception is thrown by calling MongoCursor::timeout() on the cursor or
  1206. * setting MongoCursor::$timeout. The static variable is useful for queries
  1207. * such as database commands and MongoCollection::findOne(), both of which
  1208. * implicitly use cursors.
  1209. */
  1210. <<__NativeData("ZendCompat")>>
  1211. class MongoCursorTimeoutException extends MongoCursorException {
  1212. }
  1213. /* Thrown when the driver fails to connect to the database. There are a
  1214. * number of possible error messages to help you diagnose the connection
  1215. * problem. These are: No candidate servers found Thrown when the driver
  1216. * cannot establish a connection to MongoDB (fulfilling the ReadPreferences,
  1217. * if specified). No server name given. This error occurs if you pass in ""
  1218. * as the server name, probably because of an typo with string interpolation,
  1219. * e.g., "$servr" instead of "$server". failed to get host [hostname] or port
  1220. * [portnum] from [server]. This indicated that the server string was
  1221. * malformed. "[hostname]" and "[portnum]" will be as much as the driver could
  1222. * dicipher of it. Operation in progress Connecting to the database timed
  1223. * out. Transport endpoint is not connected Generally means that the
  1224. * connection string isn't correct, the driver couldn't even find the database
  1225. * server. couldn't determine master No server in a replica set connection
  1226. * was identified as the primary. couldn't get host info for [server] This
  1227. * indicated that DNS could not resolve the server address you gave. This
  1228. * could easily be caused by a typo, for example, "server" instead of
  1229. * "$server". Invalid Argument This can be caused by attempting to connect
  1230. * to a machine that is up but that the database isn't actually running on.
  1231. * Make sure that you've started the database server before connecting.
  1232. * Permission denied This means that the socket could not be opened due to
  1233. * permissions issues. On Red Hat variants, this can be caused by a default
  1234. * setting that does not allow Apache to create network connections. You can
  1235. * override this setting by running: then restarting Apache. If the error
  1236. * message is not listed above, it is probably an error from the C socket, and
  1237. * you can search the web for its usual cause.
  1238. */
  1239. <<__NativeData("ZendCompat")>>
  1240. class MongoConnectionException extends MongoException {
  1241. }
  1242. /* Thrown when there are errors reading or writing files to or from the
  1243. * database.
  1244. */
  1245. <<__NativeData("ZendCompat")>>
  1246. class MongoGridFSException extends MongoException {
  1247. }
  1248. /* This function is very beta and entirely useless for 99% of users. It is
  1249. * only useful if you're doing something weird, such as writing your own
  1250. * driver on top of the PHP driver.
  1251. */
  1252. <<__Native("ZendCompat")>>
  1253. function bson_decode(mixed $bson): mixed;
  1254. /* This function is very beta and entirely useless for 99% of users. It is
  1255. * only useful if you're doing something weird, such as writing your own
  1256. * driver on top of the PHP driver.
  1257. */
  1258. <<__Native("ZendCompat")>>
  1259. function bson_encode(mixed $anything): mixed;