forked from JetBrains/phpstorm-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongo.php
2517 lines (2245 loc) · 106 KB
/
mongo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
* Mongo extension stubs
* Gathered from http://www.php.net/manual/en/book.mongo.php
* Maintainer: Alexander Makarov, [email protected], [email protected]
*
* MongoClient: https://github.com/djsipe/PHP-Stubs
*/
/**
* A connection between PHP and MongoDB. This class is used to create and manage connections
* See MongoClient::__construct() and the section on connecting for more information about creating connections.
* @link http://www.php.net/manual/en/class.mongoclient.php
*/
class MongoClient
{
const VERSION = '3.x';
const DEFAULT_HOST = "localhost" ;
const DEFAULT_PORT = 27017 ;
const RP_PRIMARY = "primary" ;
const RP_PRIMARY_PREFERRED = "primaryPreferred" ;
const RP_SECONDARY = "secondary" ;
const RP_SECONDARY_PREFERRED = "secondaryPreferred" ;
const RP_NEAREST = "nearest" ;
/* Properties */
public $connected = FALSE ;
public $status = NULL ;
protected $server = NULL ;
protected $persistent = NULL ;
/* Methods */
/**
* Creates a new database connection object
* @link http://php.net/manual/en/mongo.construct.php
* @param string $server [optional] The server name.
* @param array $options [optional] An array of options for the connection. Currently
* available options include: "connect" If the constructor should connect before
* returning. Default is true. "timeout" For how long the driver should try to
* connect to the database (in milliseconds). "replicaSet" The name of the replica
* set to connect to. If this is given, the master will be determined by using the
* ismaster database command on the seeds, so the driver may end up connecting to a
* server that was not even listed. See the replica set example below for details.
* "username" The username can be specified here, instead of including it in the
* host list. This is especially useful if a username has a ":" in it. This
* overrides a username set in the host list. "password" The password can be
* specified here, instead of including it in the host list. This is especially
* useful if a password has a "@" in it. This overrides a password set in the host
* list. "db" The database to authenticate against can be specified here, instead
* of including it in the host list. This overrides a database given in the host
* list "fsync" When "fsync" is set, all write operations will block until the database has flushed the changes to disk. This makes the write operations slower, but it guarantees that writes have succeeded and that the operations can be recovered in case of total system failure.
* If the MongoDB server has journaling enabled, this option is identical to "journal". If journaling is not enabled, this option ensures that write operations will be synced to database files on disk.
* "journal"
* When "journal" is set, all write operations will block until the database has flushed the changes to the journal on disk. This makes the write operations slower, but it guarantees that writes have succeeded and that the operations can be recovered in case of total system failure.
* Note: If this option is used and journaling is disabled, MongoDB 2.6+ will raise an error and the write will fail; older server versions will simply ignore the option.
* "gssapiServiceName"
* Sets the » Kerberos service principal. Only applicable when authMechanism=GSSAPI. Defaults to "mongodb".
* "password"
* The password can be specified here, instead of including it in the host list. This is especially useful if a password has a "@" in it. This overrides a password set in the host list.
* "readPreference"
* Specifies the read preference type. Read preferences provide you with control from which secondaries data can be read from.
* Allowed values are: MongoClient::RP_PRIMARY, MongoClient::RP_PRIMARY_PREFERRED, MongoClient::RP_SECONDARY, MongoClient::RP_SECONDARY_PREFERRED and MongoClient::RP_NEAREST.
* See the documentation on read preferences for more information.
* "readPreferenceTags"
* Specifies the read preference tags as an array of strings. Tags can be used in combination with the readPreference option to further control which secondaries data might be read from.
* See the documentation on read preferences for more information.
* "replicaSet"
* The name of the replica set to connect to. If this is given, the primary will be automatically be determined. This means that the driver may end up connecting to a server that was not even listed. See the replica set example below for details.
* "secondaryAcceptableLatencyMS"
* When reading from a secondary (using ReadPreferences), do not read from secondaries known to be more then secondaryAcceptableLatencyMS away from us. Defaults to 15
* "socketTimeoutMS"
* How long a socket operation (read or write) can take before timing out in milliseconds. Defaults to 30000 (30 seconds).
* If -1 is specified, socket operations may block indefinitely. This option may also be set on a per-operation basis using MongoCursor::timeout() for queries or the "socketTimeoutMS" option for write methods.
* Note: This is a client-side timeout. If a write operation times out, there is no way to know if the server actually handled the write or not, as a MongoCursorTimeoutException will be thrown in lieu of returning a write result.
* "ssl"
* A boolean to specify whether you want to enable SSL for the connections to MongoDB. Extra options such as certificates can be set with SSL context options.
* "username"
* The username can be specified here, instead of including it in the host list. This is especially useful if a username has a ":" in it. This overrides a username set in the host list.
* "w"
* The w option specifies the Write Concern for the driver, which determines how long the driver blocks when writing. The default value is 1.
* This option is applicable when connecting to both single servers and replica sets. A positive value controls how many nodes must acknowledge the write instruction before the driver continues. A value of 1 would require the single server or primary (in a replica set) to acknowledge the write operation. A value of 3 would cause the driver to block until the write has been applied to the primary as well as two secondary servers (in a replica set).
* A string value is used to control which tag sets are taken into account for write concerns. "majority" is special and ensures that the write operation has been applied to the majority (more than 50%) of the participating nodes.
* "wTimeoutMS" This option specifies the time limit, in milliseconds, for write concern acknowledgement. It is only applicable for write operations where "w" is greater than 1, as the timeout pertains to replication. If the write concern is not satisfied within the time limit, a MongoCursorException will be thrown. A value of 0 may be specified to block indefinitely. The default value is 10000 (ten seconds).
* @param array $driver_options [optional] <p>
* An array of options for the MongoDB driver. Options include setting
* connection {@link http://php.net/manual/en/mongo.connecting.ssl.php#mongo.connecting.context.ssl context options for SSL}
* or {@link http://php.net/manual/en/context.mongodb.php logging callbacks}.
* </p><ul>
* <li>
* <p>
* <em>"context"</em>
* </p>
* <p>
* The Stream Context to attach to all new connections. This allows you
* for example to configure SSL certificates and are described at
* {@link http://php.net/manual/en/context.ssl.php SSL context options}. See the
* {@link http://php.net/manual/en/mongo.connecting.ssl.php#mongo.connecting.context.ssl Connecting over SSL} tutorial.
* </p>
* </li>
* </ul>
* @return MongoClient
* Returns a new database connection object*
* @throws MongoConnectionException
*/
public function __construct($server = "mongodb://localhost:27017", array $options = array("connect" => TRUE), $driver_options) {}
/**
* (PECL mongo >= 1.3.0)<br/>
* Closes this database connection
* This method does not need to be called, except in unusual circumstances.
* The driver will cleanly close the database connection when the Mongo object goes out of scope.
* @link http://www.php.net/manual/en/mongoclient.close.php
* @param boolean|string $connection [optional] <p>
* If connection is not given, or <b>FALSE</b> then connection that would be selected for writes would be closed. In a single-node configuration, that is then the whole connection, but if you are connected to a replica set, close() will only close the connection to the primary server.
* If connection is <b>TRUE</b> then all connections as known by the connection manager will be closed. This can include connections that are not referenced in the connection string used to create the object that you are calling close on.
* If connection is a string argument, then it will only close the connection identified by this hash. Hashes are identifiers for a connection and can be obtained by calling {@see MongoClient::getConnections()}.
* </p>
* @return boolean If the connection was successfully closed.
*/
public function close($connection) {}
/**
* Connects to a database server
*
* @link http://www.php.net/manual/en/mongoclient.connect.php
*
* @throws MongoConnectionException
* @return boolean If the connection was successful.
*/
public function connect() {}
/**
* @deprecated Use MongoDB::drop() instead.
* Drops a database
*
* @link http://www.php.net/manual/en/mongoclient.dropdb.php
* @param mixed $db The database to drop. Can be a MongoDB object or the name of the database.
* @return array The database response.
*/
public function dropDB($db) {}
/**
* (PECL mongo >= 1.3.0)<br/>
* Gets a database
* @link http://php.net/manual/en/mongoclient.get.php
* @param string $dbname The database name.
* @return MongoDB The database name.
*/
public function __get ($dbname)
{}
/**
* Get connections
* Returns an array of all open connections, and information about each of the servers
* @static
* @return array
*/
static public function getConnections ()
{}
/**
* Get hosts
* This method is only useful with a connection to a replica set. It returns the status of all of the hosts in the
* set. Without a replica set, it will just return an array with one element containing the host that you are
* connected to.
* @return array
*/
public function getHosts ()
{}
/**
* Get read preference
* Get the read preference for this connection
* @return array
*/
public function getReadPreference ()
{}
/**
* (PECL mongo >= 1.5.0)<br/>
* Get the write concern for this connection
* @return array <p>This function returns an array describing the write concern.
* The array contains the values w for an integer acknowledgement level or string mode,
* and wtimeout denoting the maximum number of milliseconds to wait for the server to satisfy the write concern.</p>
*/
public function getWriteConcern () {}
/**
* Kills a specific cursor on the server
* @link http://www.php.net/manual/en/mongoclient.killcursor.php
* @param string $server_hash <p>
* The server hash that has the cursor. This can be obtained through
* {@link http://www.php.net/manual/en/mongocursor.info.php MongoCursor::info()}.
* </p>
* @param int|MongoInt64 $id
* <p>
* The ID of the cursor to kill. You can either supply an {@link http://www.php.net/manual/en/language.types.integer.php int}
* containing the 64 bit cursor ID, or an object of the
* {@link http://www.php.net/manual/en/class.mongoint64.php MongoInt64} class. The latter is necessary on 32
* bit platforms (and Windows).
* </p>
*/
public function killCursor ( $server_hash , $id) {}
/**
* (PECL mongo >= 1.3.0)<br/>
* Lists all of the databases available
* @link http://php.net/manual/en/mongoclient.listdbs.php
* @return array Returns an associative array containing three fields. The first field is databases, which in turn contains an array. Each element of the array is an associative array corresponding to a database, giving the database's name, size, and if it's empty. The other two fields are totalSize (in bytes) and ok, which is 1 if this method ran successfully.
*/
public function listDBs() {}
/**
* (PECL mongo >= 1.3.0)<br/>
* Gets a database collection
* @link http://www.php.net/manual/en/mongoclient.selectcollection.php
* @param string $db The database name.
* @param string $collection The collection name.
* @throws Exception Throws Exception if the database or collection name is invalid.
* @return MongoCollection Returns a new collection object.
*/
public function selectCollection($db, $collection) {}
/**
* (PECL mongo >= 1.3.0)<br/>
* Gets a database
* @link http://www.php.net/manual/en/mongo.selectdb.php
* @param string $name The database name.
* @throws InvalidArgumentException
* @return MongoDB Returns a new db object.
*/
public function selectDB($name) {}
/**
* (PECL mongo >= 1.3.0)<br/>
* Set read preference
* @param string $readPreference
* @param array $tags
* @return bool
*/
public function setReadPreference ($readPreference, $tags=null)
{}
/**
* (PECL mongo >= 1.1.0)<br/>
* Choose a new secondary for slaveOkay reads
* @link www.php.net/manual/en/mongo.switchslave.php
* @return string The address of the secondary this connection is using for reads. This may be the same as the previous address as addresses are randomly chosen. It may return only one address if only one secondary (or only the primary) is available.
* For example, if we had a three member replica set with a primary, secondary, and arbiter this method would always return the address of the secondary. If the secondary became unavailable, this method would always return the address of the primary. If the primary also became unavailable, this method would throw an exception, as an arbiter cannot handle reads.
* @throws MongoException (error code 15) if it is called on a non-replica-set connection. It will also throw MongoExceptions if it cannot find anyone (primary or secondary) to read from (error code 16).
*
*/
public function switchSlave() {}
/**
* String representation of this connection
* @link http://www.php.net/manual/en/mongoclient.tostring.php
* @return string Returns hostname and port for this connection.
*/
public function __toString() {}
}
/**
* The connection point between MongoDB and PHP.
* This class is used to initiate a connection and for database server commands.
* @link http://www.php.net/manual/en/class.mongo.php
* @deprecated This class has been DEPRECATED as of version 1.3.0.
* Relying on this feature is highly discouraged. Please use MongoClient instead.
* @see MongoClient
*/
class Mongo extends MongoClient {
/**
* @deprecated This feature has been DEPRECATED as of version 1.2.3. Relying on this feature is highly discouraged. Please use MongoPool::getSize() instead.
* (PECL mongo >= 1.2.0)<br/>
* Get pool size for connection pools
* @link http://php.net/manual/en/mongo.getpoolsize.php
* @return int Returns the current pool size.
*/
public function getPoolSize() {}
/**
* (PECL mongo >= 1.1.0)<br/>
* Returns the address being used by this for slaveOkay reads
* @link http://php.net/manual/en/mongo.getslave.php
* @return bool <p>The address of the secondary this connection is using for reads.
* </p>
* <p>
* This returns <b>NULL</b> if this is not connected to a replica set or not yet
* initialized.
* </p>
*/
public function getSlave() {}
/**
* (PECL mongo >= 1.1.0)<br/>
* Get slaveOkay setting for this connection
* @link http://php.net/manual/en/mongo.getslaveokay.php
* @return bool Returns the value of slaveOkay for this instance.
*/
public function getSlaveOkay() {}
/**
* Connects to paired database server
* @deprecated Pass a string of the form "mongodb://server1,server2" to the constructor instead of using this method.
* @link http://www.php.net/manual/en/mongo.pairconnect.php
* @throws MongoConnectionException
* @return boolean
*/
public function pairConnect() {}
/**
* (PECL mongo >= 1.2.0)<br/>
* @deprecated This feature has been DEPRECATED as of version 1.2.3. Relying on this feature is highly discouraged. Please use MongoPool::info() instead.
* Returns information about all connection pools.
* @link http://php.net/manual/en/mongo.pooldebug.php
* @return array Each connection pool has an identifier, which starts with the host. For each pool, this function shows the following fields:
* <p><b>in use</b></p>
* <p>The number of connections currently being used by MongoClient instances.
* in pool
* The number of connections currently in the pool (not being used).</p>
* <p><b>remaining</b></p>
*
* <p>The number of connections that could be created by this pool. For example, suppose a pool had 5 connections remaining and 3 connections in the pool. We could create 8 new instances of MongoClient before we exhausted this pool (assuming no instances of MongoClient went out of scope, returning their connections to the pool).
*
* A negative number means that this pool will spawn unlimited connections.
*
* Before a pool is created, you can change the max number of connections by calling Mongo::setPoolSize(). Once a pool is showing up in the output of this function, its size cannot be changed.</p>
* <p><b>timeout</b></p>
*
* <p>The socket timeout for connections in this pool. This is how long connections in this pool will attempt to connect to a server before giving up.</p>
*
*/
public function poolDebug() {}
/**
* (PECL mongo >= 1.1.0)<br/>
* Change slaveOkay setting for this connection
* @link http://php.net/manual/en/mongo.setslaveokay.php
* @param bool $ok [optional] <p class="para">
* If reads should be sent to secondary members of a replica set for all
* possible queries using this {@see MongoClient} instance.
* </p>
* @return bool returns the former value of slaveOkay for this instance.
*/
public function setSlaveOkay ($ok) {}
/**
* @deprecated Relying on this feature is highly discouraged. Please use MongoPool::setSize() instead.
*(PECL mongo >= 1.2.0)<br/>
* Set the size for future connection pools.
* @link http://php.net/manual/en/mongo.setpoolsize.php
* @param $size <p>The max number of connections future pools will be able to create. Negative numbers mean that the pool will spawn an infinite number of connections.</p>
* @return bool Returns the former value of pool size.
*/
public function setPoolSize($size) {}
/**
* Creates a persistent connection with a database server
* @link http://www.php.net/manual/en/mongo.persistconnect.php
* @deprecated Pass array("persist" => $id) to the constructor instead of using this method.
* @param string $username A username used to identify the connection.
* @param string $password A password used to identify the connection.
* @throws MongoConnectionException
* @return boolean If the connection was successful.
*/
public function persistConnect($username = "", $password = "") {}
/**
* Creates a persistent connection with paired database servers
* @deprecated Pass "mongodb://server1,server2" and array("persist" => $id) to the constructor instead of using this method.
* @link http://www.php.net/manual/en/mongo.pairpersistconnect.php
* @param string $username A username used to identify the connection.
* @param string $password A password used to identify the connection.
* @throws MongoConnectionException
* @return boolean If the connection was successful.
*/
public function pairPersistConnect($username = "", $password = "") {}
/**
* Connects with a database server
*
* @link http://www.php.net/manual/en/mongo.connectutil.php
* @throws MongoConnectionException
* @return boolean If the connection was successful.
*/
protected function connectUtil() {}
/**
* Check if there was an error on the most recent db operation performed
* @deprecated Use MongoDB::lastError() instead.
* @link http://www.php.net/manual/en/mongo.lasterror.php
* @return array|null Returns the error, if there was one, or NULL.
*/
public function lastError() {}
/**
* Checks for the last error thrown during a database operation
* @deprecated Use MongoDB::prevError() instead.
* @link http://www.php.net/manual/en/mongo.preverror.php
* @return array Returns the error and the number of operations ago it occurred.
*/
public function prevError() {}
/**
* Clears any flagged errors on the connection
* @deprecated Use MongoDB::resetError() instead.
* @link http://www.php.net/manual/en/mongo.reseterror.php
* @return array Returns the database response.
*/
public function resetError() {}
/**
* Creates a database error on the database.
* @deprecated Use MongoDB::forceError() instead.
* @link http://www.php.net/manual/en/mongo.forceerror.php
* @return boolean The database response.
*/
public function forceError() {}
}
/**
* Instances of this class are used to interact with a database.
* @link http://www.php.net/manual/en/class.mongodb.php
*/
class MongoDB {
/**
* Profiling is off.
* @link http://php.net/manual/en/class.mongodb.php#mongodb.constants.profiling-off
*/
const PROFILING_OFF = 0;
/**
* Profiling is on for slow operations (>100 ms).
* @link http://php.net/manual/en/class.mongodb.php#mongodb.constants.profiling-slow
*/
const PROFILING_SLOW = 1;
/**
* Profiling is on for all operations.
* @link http://php.net/manual/en/class.mongodb.php#mongodb.constants.profiling-on
*/
const PROFILING_ON = 2;
/**
* @var int
* <p>
* The number of servers to replicate a change to before returning success.
* Inherited by instances of {@link http://php.net/manual/en/class.mongocollection.php MongoCollection} derived
* from this. <em>w</em> functionality is only available in
* version 1.5.1+ of the MongoDB server and 1.0.8+ of the driver.
* </p>
* <p>
* <em>w</em> is used whenever you need to adjust the
* acknowledgement level
* ( {@link http://php.net/manual/en/mongocollection.insert.php MongoCollection::insert()},
* {@link http://php.net/manual/en/mongocollection.update.php MongoCollection::update()},
* {@link http://php.net/manual/en/mongocollection.remove.php MongoCollection::remove()},
* {@link http://php.net/manual/en/mongocollection.save.php MongoCollection::save()}, and
* {@link http://php.net/manual/en/mongocollection.ensureindex.php MongoCollection::ensureIndex()} all support this
* option). With the default value (1), an acknowledged operation will return once
* the database server has the operation. If the server goes down before
* the operation has been replicated to a secondary, it is possible to lose
* the operation forever. Thus, you can specify <em>w</em> to be
* higher than one and guarantee that at least one secondary has the
* operation before it is considered successful.
* </p>
* <p>
* For example, if <em>w</em> is 2, the primary and one secondary
* must have a record of the operation or the driver will throw a
* {@link http://php.net/manual/en/class.mongocursorexception.php MongoCursorException}. It is tempting to set
* <em>w</em> to the total number of secondaries + primary, but
* then if one secondary is down the operation will fail and an exception
* will be thrown, so usually <em>w=2</em> is safest (primary and
* one secondary).
* </p>
*/
public $w = 1;
/**
* @var int <p>
* T he number of milliseconds to wait for <em>MongoDB::$w</em>
* replications to take place. Inherited by instances of
* {@link http://www.php.net/manual/en/class.mongocollection.php MongoCollection} derived from this.
* <em>w</em> functionality is only available in version 1.5.1+ of
* the MongoDB server and 1.0.8+ of the driver.
* </p>
* <p>
* Unless <em>wtimeout</em> is set, the server waits forever for
* replicating to <em>w</em> servers to finish. The driver
* defaults to waiting for 10 seconds, you can change this value to alter
* its behavior.
* </p>
*/
public $wtimeout = 10000;
/**
* (PECL mongo >= 0.9.0)<br/>
* Creates a new database
* This method is not meant to be called directly. The preferred way to create an instance of MongoDB is through {@see Mongo::__get()} or {@see Mongo::selectDB()}.
* @link http://www.php.net/manual/en/mongodb.construct.php
* @param MongoClient $conn Database connection.
* @param string $name Database name.
* @throws Exception
* @return MongoDB Returns the database.
*/
public function __construct($conn, $name) {}
/**
* The name of this database
* @link http://www.php.net/manual/en/mongodb.--tostring.php
* @return string Returns this database's name.
*/
public function __toString() {}
/**
* (PECL mongo >= 1.0.2)<br/>
* Gets a collection
* @link http://www.php.net/manual/en/mongodb.get.php
* @param string $name The name of the collection.
* @return MongoCollection
*/
public function __get($name) {}
/**
* (PECL mongo >= 1.3.0)<br/>
* @link http://www.php.net/manual/en/mongodb.getcollectionnames.php
* Get all collections from this database
* @param bool $includeSystemCollections [optional] Include system collections.
* @return array Returns the names of the all the collections in the database as an
* {@link http://www.php.net/manual/en/language.types.array.php array}.
*/
public function getCollectionNames($includeSystemCollections = false) {}
/**
* (PECL mongo >= 0.9.0)<br/>
* Fetches toolkit for dealing with files stored in this database
* @link http://www.php.net/manual/en/mongodb.getgridfs.php
* @param string $prefix [optional] The prefix for the files and chunks collections.
* @return MongoGridFS Returns a new gridfs object for this database.
*/
public function getGridFS($prefix = "fs") {}
/**
* (PECL mongo >= 0.9.0)<br/>
* Gets this database's profiling level
* @link http://www.php.net/manual/en/mongodb.getprofilinglevel.php
* @return int Returns the profiling level.
*/
public function getProfilingLevel() {}
/**
* (PECL mongo >= 1.1.0)<br/>
* Get slaveOkay setting for this database
* @link http://www.php.net/manual/en/mongodb.getslaveokay.php
* @return bool Returns the value of slaveOkay for this instance.
*/
public function getSlaveOkay () {}
/**
* (PECL mongo >= 0.9.0)<br/>
* Sets this database's profiling level
* @link http://www.php.net/manual/en/mongodb.setprofilinglevel.php
* @param int $level Profiling level.
* @return int Returns the previous profiling level.
*/
public function setProfilingLevel($level) {}
/**
* (PECL mongo >= 0.9.0)<br/>
* Drops this database
* @link http://www.php.net/manual/en/mongodb.drop.php
* @return array Returns the database response.
*/
public function drop() {}
/**
* Repairs and compacts this database
* @link http://www.php.net/manual/en/mongodb.repair.php
* @param bool $preserve_cloned_files [optional] <p>If cloned files should be kept if the repair fails.</p>
* @param bool $backup_original_files [optional] <p>If original files should be backed up.</p>
* @return array <p>Returns db response.</p>
*/
public function repair($preserve_cloned_files = FALSE, $backup_original_files = FALSE) {}
/**
* (PECL mongo >= 0.9.0)<br/>
* Gets a collection
* @link http://www.php.net/manual/en/mongodb.selectcollection.php
* @param string $name <b>The collection name.</b>
* @throws Exception if the collection name is invalid.
* @return MongoCollection <p>
* Returns a new collection object.
* </p>
*/
public function selectCollection($name) {}
/**
* (PECL mongo >= 1.1.0)<br/>
* Change slaveOkay setting for this database
* @link http://php.net/manual/en/mongodb.setslaveokay.php
* @param bool $ok [optional] <p>
* If reads should be sent to secondary members of a replica set for all
* possible queries using this {@link http://www.php.net/manual/en/class.mongodb.php MongoDB} instance.
* </p>
* @return bool Returns the former value of slaveOkay for this instance.
*/
public function setSlaveOkay ($ok = true) {}
/**
* Creates a collection
* @link http://www.php.net/manual/en/mongodb.createcollection.php
* @param string $name The name of the collection.
* @param array $options [optional] <p>
* <p>
* An array containing options for the collections. Each option is its own
* element in the options array, with the option name listed below being
* the key of the element. The supported options depend on the MongoDB
* server version. At the moment, the following options are supported:
* </p>
* <p>
* <b>capped</b>
* <p>
* If the collection should be a fixed size.
* </p>
* </p>
* <p>
* <b>size</b>
* <p>
* If the collection is fixed size, its size in bytes.</p></p>
* <p><b>max</b>
* <p>If the collection is fixed size, the maximum number of elements to store in the collection.</p></p>
* <i>autoIndexId</i>
*
* <p>
* If capped is <b>TRUE</b> you can specify <b>FALSE</b> to disable the
* automatic index created on the <em>_id</em> field.
* Before MongoDB 2.2, the default value for
* <em>autoIndexId</em> was <b>FALSE</b>.
* </p>
* </p>
* @return MongoCollection <p>Returns a collection object representing the new collection.</p>
*/
public function createCollection($name, $options) {}
/**
* (PECL mongo >= 0.9.0)<br/>
* @deprecated Use MongoCollection::drop() instead.
* Drops a collection
* @link http://www.php.net/manual/en/mongodb.dropcollection.php
* @param MongoCollection|string $coll MongoCollection or name of collection to drop.
* @return array Returns the database response.
*/
public function dropCollection($coll) {}
/**
* (PECL mongo >= 0.9.0)<br/>
* Get a list of collections in this database
* @link http://www.php.net/manual/en/mongodb.listcollections.php
* @param bool $includeSystemCollections [optional] <p>Include system collections.</p>
* @return array Returns a list of MongoCollections.
*/
public function listCollections($includeSystemCollections = false) {}
/**
* (PECL mongo >= 0.9.0)<br/>
* Creates a database reference
* @link http://www.php.net/manual/en/mongodb.createdbref.php
* @param string $collection The collection to which the database reference will point.
* @param mixed $document_or_id <p>
* If an array or object is given, its <em>_id</em> field will be
* used as the reference ID. If a {@see MongoId} or scalar
* is given, it will be used as the reference ID.
* </p>
* @return array <p>Returns a database reference array.</p>
* <p>
* If an array without an <em>_id</em> field was provided as the
* <em>document_or_id</em> parameter, <b>NULL</b> will be returned.
* </p>
*/
public function createDBRef($collection, $document_or_id) {}
/**
* (PECL mongo >= 0.9.0)<br/>
* Fetches the document pointed to by a database reference
* @link http://www.php.net/manual/en/mongodb.getdbref.php
* @param array $ref A database reference.
* @return array Returns the document pointed to by the reference.
*/
public function getDBRef(array $ref) {}
/**
* (PECL mongo >= 1.5.0)<br/>
* Get the write concern for this database
* @link http://php.net/manual/en/mongodb.getwriteconcern.php
* @return array <p>This function returns an array describing the write concern.
* The array contains the values w for an integer acknowledgement level or string mode,
* and wtimeout denoting the maximum number of milliseconds to wait for the server to satisfy the write concern.</p>
*/
public function getWriteConcern() {}
/**
* (PECL mongo >= 0.9.3)<br/>
* Runs JavaScript code on the database server.
* @link http://www.php.net/manual/en/mongodb.execute.php
* @param MongoCode|string $code Code to execute.
* @param array $args [optional] Arguments to be passed to code.
* @return array Returns the result of the evaluation.
*/
public function execute($code, array $args = array()) {}
/**
* Execute a database command
* @link http://www.php.net/manual/en/mongodb.command.php
* @param array $data The query to send.
* @param array() $options [optional] <p>
* This parameter is an associative array of the form
* <em>array("optionname" => <boolean>, ...)</em>. Currently
* supported options are:
* </p><ul>
* <li><p><em>"timeout"</em></p><p>Deprecated alias for <em>"socketTimeoutMS"</em>.</p></li>
* </ul>
* @return array Returns database response.
* Every database response is always maximum one document,
* which means that the result of a database command can never exceed 16MB.
* The resulting document's structure depends on the command,
* but most results will have the ok field to indicate success or failure and results containing an array of each of the resulting documents.
*/
public function command(array $data, $options) {}
/**
* (PECL mongo >= 0.9.5)<br/>
* Check if there was an error on the most recent db operation performed
* @link http://www.php.net/manual/en/mongodb.lasterror.php
* @return array Returns the error, if there was one.
*/
public function lastError() {}
/**
* (PECL mongo >= 0.9.5)<br/>
* Checks for the last error thrown during a database operation
* @link http://www.php.net/manual/en/mongodb.preverror.php
* @return array Returns the error and the number of operations ago it occurred.
*/
public function prevError() {}
/**
* (PECL mongo >= 0.9.5)<br/>
* Clears any flagged errors on the database
* @link http://www.php.net/manual/en/mongodb.reseterror.php
* @return array Returns the database response.
*/
public function resetError() {}
/**
* (PECL mongo >= 0.9.5)<br/>
* Creates a database error
* @link http://www.php.net/manual/en/mongodb.forceerror.php
* @return boolean Returns the database response.
*/
public function forceError() {}
/**
* (PECL mongo >= 1.0.1)<br/>
* Log in to this database
* @link http://www.php.net/manual/en/mongodb.authenticate.php
* @param string $username The username.
* @param string $password The password (in plaintext).
* @return array <p>Returns database response. If the login was successful, it will return 1.</p>
* <p>
* <span style="color: #0000BB"><?php<br></span><span style="color: #007700">array(</span><span style="color: #DD0000">"ok" </span><span style="color: #007700">=> </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br></span><span style="color: #0000BB">?></span>
* </span>
* </code></div>
* </div>
* </p>
* <p> If something went wrong, it will return </p>
* <p>
* <div class="example-contents">
* <div class="phpcode"><code><span style="color: #000000">
* <span style="color: #0000BB"><?php<br></span><span style="color: #007700">array(</span><span style="color: #DD0000">"ok" </span><span style="color: #007700">=> </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">"errmsg" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"auth fails"</span><span style="color: #007700">);<br></span><span style="color: #0000BB">?></span></p>
* <p>("auth fails" could be another message, depending on database version and
* what went wrong)</p>
*/
public function authenticate($username, $password) {}
/**
* (PECL mongo >= 1.3.0)<br/>
* Get the read preference for this database
* @link http://www.php.net/manual/en/mongodb.getreadpreference.php
* @return array This function returns an array describing the read preference. The array contains the values type for the string read preference mode (corresponding to the MongoClient constants), and tagsets containing a list of all tag set criteria. If no tag sets were specified, tagsets will not be present in the array.
*/
public function getReadPreference () {}
/**
* (PECL mongo >= 1.3.0)<br/>
* Set the read preference for this database
* @link http://www.php.net/manual/en/mongodb.setreadpreference.php
* @param string $read_preference <p>The read preference mode: <b>MongoClient::RP_PRIMARY</b>, <b>MongoClient::RP_PRIMARY_PREFERRED</b>, <b>MongoClient::RP_SECONDARY</b>, <b>MongoClient::RP_SECONDARY_PREFERRED</b>, or <b>MongoClient::RP_NEAREST</b>.</p>
* @param array $tags [optional] <p>An array of zero or more tag sets, where each tag set is itself an array of criteria used to match tags on replica set members.</p>
* @return boolean Returns <b>TRUE</b> on success, or <b>FALSE</b> otherwise.
*/
public function setReadPreference ($read_preference, array $tags) {}
/**
* (PECL mongo >= 1.5.0)<br/>
* @link http://php.net/manual/en/mongodb.setwriteconcern.php
* Set the write concern for this database
* @param mixed $w <p>The write concern. This may be an integer denoting the number of servers required to acknowledge the write, or a string mode (e.g. "majority").</p>
* @param int $wtimeout[optional] <p>The maximum number of milliseconds to wait for the server to satisfy the write concern.</p>
* @return boolean Returns <b>TRUE</b> on success, or <b>FALSE</b> otherwise.
*/
public function setWriteConcern($w, $wtimeout) {}
}
/**
* Represents a database collection.
* @link http://www.php.net/manual/en/class.mongocollection.php
*/
class MongoCollection {
/**
* @link http://php.net/manual/en/class.mongocollection.php#mongocollection.constants.ascending
*/
const ASCENDING = 1;
/**
* @link http://php.net/manual/en/class.mongocollection.php#mongocollection.constants.descending
*/
const DESCENDING = -1;
/**
* @var MongoDB
*/
public $db = NULL ;
/**
* @var int<p>
* The number of servers to replicate a change to before returning success.
* Value is inherited from the parent database. The
* {@link http://www.php.net/manual/en/class.mongodb.php MongoDB} class has a more detailed description of
* how <em>w</em> works.
* </p>
*/
public $w;
/**
* @var int <p>
* The number of milliseconds to wait for <em>$this->w</em>
* replications to take place. Value is inherited from the parent database.
* The {@link http://www.php.net/manual/en/class.mongodb.php MongoDB} class has a more detailed description
* of how <em>wtimeout</em> works.
* </p>
*/
public $wtimeout;
/**
* Creates a new collection
* @link http://www.php.net/manual/en/mongocollection.construct.php
* @param MongoDB $db Parent database.
* @param string $name Name for this collection.
* @throws Exception
* @return MongoCollection
*/
public function __construct(MongoDB $db, $name) {}
/**
* String representation of this collection
* @link http://www.php.net/manual/en/mongocollection.--tostring.php
* @return string Returns the full name of this collection.
*/
public function __toString() {}
/**
* Gets a collection
* @link http://www.php.net/manual/en/mongocollection.get.php
* @param string $name The next string in the collection name.
* @return MongoCollection
*/
public function __get($name) {}
/**
* (PECL mongo >= 1.3.0)<br/>
* <p>
* The MongoDB
* {@link http://docs.mongodb.org/manual/applications/aggregation/ aggregation framework}
* provides a means to calculate aggregated values without having to use
* MapReduce. While MapReduce is powerful, it is often more difficult than
* necessary for many simple aggregation tasks, such as totaling or averaging
* field values.
* </p>
* <p>
* This method accepts either a variable amount of pipeline operators, or a
* single array of operators constituting the pipeline.
* </p>
* @link http://www.php.net/manual/en/mongocollection.aggregate.php
* @param array $pipeline <p> An array of pipeline operators, or just the first operator. </p>
* @param array $op [optional] <p> The second pipeline operator.</p>
* @param array $pipelineOperators [optional] <p> Additional pipeline operators. </p>
* @return array The result of the aggregation as an array. The ok will be set to 1 on success, 0 on failure.
*/
public function aggregate ( array $pipeline, array $op, array $pipelineOperators ) {}
/**
* (PECL mongo >= 1.5.0)<br/>
*
* <p>
* With this method you can execute Aggregation Framework pipelines and retrieve the results
* through a cursor, instead of getting just one document back as you would with
* {@link http://php.net/manual/en/mongocollection.aggregate.php MongoCollection::aggregate()}.
* This method returns a {@link http://php.net/manual/en/class.mongocommandcursor.php MongoCommandCursor} object.
* This cursor object implements the {@link http://php.net/manual/en/class.iterator.php Iterator} interface
* just like the {@link http://php.net/manual/en/class.mongocursor.php MongoCursor} objects that are returned
* by the {@link http://php.net/manual/en/mongocollection.find.php MongoCollection::find()} method
* </p>
*
* @link http://php.net/manual/en/mongocollection.aggregatecursor.php
*
* @param array $pipeline <p> The Aggregation Framework pipeline to execute. </p>
* @param array $options [optional] <p> Options for the aggregation command </p>
*
* @return MongoCommandCursor Returns a {@link http://php.net/manual/en/class.mongocommandcursor.php MongoCommandCursor} object
*/
public function aggregateCursor(array $pipeline, array $options) {}
/**
* Returns this collection's name
* @link http://www.php.net/manual/en/mongocollection.getname.php
* @return string
*/
public function getName() {}
/**
* (PECL mongo >= 1.1.0)<br/>
* <p>
* See {@link http://www.php.net/manual/en/mongo.queries.php the query section} of this manual for
* information on distributing reads to secondaries.
* </p>
* @link http://www.php.net/manual/en/mongocollection.getslaveokay.php
* @return bool Returns the value of slaveOkay for this instance.
*/
public function getSlaveOkay() { }
/**
* (PECL mongo >= 1.1.0)<br/>
* <p>
* See {@link http://www.php.net/manual/en/mongo.queries.php the query section} of this manual for
* information on distributing reads to secondaries.
* </p>
* @link http://www.php.net/manual/en/mongocollection.setslaveokay.php
* @param bool $ok [optional] <p>
* If reads should be sent to secondary members of a replica set for all
* possible queries using this {@link http://www.php.net/manual/en/class.mongocollection.php MongoCollection}
* instance.
* @return bool Returns the former value of slaveOkay for this instance.
* </p>
*/
public function setSlaveOkay($ok = true) { }
/**
* (PECL mongo >= 1.3.0)<br/>
* @link http://www.php.net/manual/en/mongocollection.getreadpreference.php
* @return array This function returns an array describing the read preference. The array contains the values <em>type</em> for the string read preference mode
* (corresponding to the {@link http://www.php.net/manual/en/class.mongoclient.php MongoClient} constants), and <em>tagsets</em> containing a list of all tag set criteria. If no tag sets were specified, <em>tagsets</em> will not be present in the array.
*/
public function getReadPreference() { }
/**
* (PECL mongo >= 1.3.0)<br/>
* @param string $read_preference <p>The read preference mode: <b>MongoClient::RP_PRIMARY</b>, <b>MongoClient::RP_PRIMARY_PREFERRED</b>, <b>MongoClient::RP_SECONDARY</b>, <b>MongoClient::RP_SECONDARY_PREFERRED</b>, or <b>MongoClient::RP_NEAREST</b>.</p>
* @param array $tags [optional] <p>An array of zero or more tag sets, where each tag set is itself an array of criteria used to match tags on replica set members.<p>
* @return bool Returns <b>TRUE</b> on success, or <b>FALSE</b> otherwise.
*/
public function setReadPreference($read_preference, array $tags) { }
/**
* Drops this collection
* @link http://www.php.net/manual/en/mongocollection.drop.php
* @return array Returns the database response.
*/
public function drop() {}
/**
* Validates this collection
* @link http://www.php.net/manual/en/mongocollection.validate.php
* @param bool $scan_data Only validate indices, not the base collection.
* @return array Returns the database's evaluation of this object.
*/
public function validate($scan_data = FALSE) {}
/**
* Inserts an array into the collection
* @link http://www.php.net/manual/en/mongocollection.insert.php
* @param array|object $a An array or object. If an object is used, it may not have protected or private properties.
* Note: If the parameter does not have an _id key or property, a new MongoId instance will be created and assigned to it.
* This special behavior does not mean that the parameter is passed by reference.
* @param array $options Options for the insert.
* <dl>
* <dt>"w"
* <dd>See WriteConcerns. The default value for MongoClient is 1.
* <dt>"fsync"
* <dd>Boolean, defaults to FALSE. Forces the insert to be synced to disk before returning success. If TRUE, an acknowledged insert is implied and will override setting w to 0.
* <dt>"timeout"
* <dd>Integer, defaults to MongoCursor::$timeout. If "safe" is set, this sets how long (in milliseconds) for the client to wait for a database response. If the database does not respond within the timeout period, a MongoCursorTimeoutException will be thrown.
* <dt>"safe"
* <dd>Deprecated. Please use the WriteConcern w option.
* </dl>
* @throws MongoException if the inserted document is empty or if it contains zero-length keys. Attempting to insert an object with protected and private properties will cause a zero-length key error.