PageRenderTime 408ms CodeModel.GetById 186ms app.highlight 156ms RepoModel.GetById 1ms app.codeStats 4ms

/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

Large files files are truncated, but you can click here to view the full file

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

Large files files are truncated, but you can click here to view the full file