Configurația la rulare

Comportamentul acestor funcții este afectat de parametrii stabiliți în php.ini.

Mongo Opțiuni de configurare pentru
Denumire Valoare implicită Poate fi modificată Jurnal al modificărilor
mongo.allow_empty_keys 0 PHP_INI_ALL  
mongo.allow_persistent 1 PHP_INI_ALL Removed in 1.2.0
mongo.chunk_size 262144 PHP_INI_ALL  
mongo.cmd "$" PHP_INI_ALL  
mongo.default_host "localhost" PHP_INI_ALL  
mongo.default_port 27017 PHP_INI_ALL  
mongo.is_master_interval 15 PHP_INI_ALL Added in 1.2.10, before 1.3.0 the default value was 60.
mongo.long_as_object 0 PHP_INI_ALL  
mongo.native_long 1 PHP_INI_ALL Before 1.5.0, the default value was 0.
mongo.ping_interval 5 PHP_INI_ALL Added in 1.2.10
mongo.utf8 1 PHP_INI_ALL  
Pentru mai multe detalii și definiții ale modurilor PHP_INI_* accesați Where a configuration setting may be set.

Iată o explicație pe scurt a directivelor de configurare.

mongo.allow_empty_keys int

Added in version 1.0.11.

If empty strings ("") should be allowed as key names. By default, the driver will throw an exception if you attempt to pass the empty string as a key to the database. It is extremely easy to do this inavertently by using double quotes with $-operators, so it is recommended that you leave this setting as default. However, if you need to save keys that are empty strings, you can set this option to true and the driver will allow you to pass empty strings to the database.

mongo.allow_persistent int

If persistent connections are allowed. (Removed in 1.2.0 - all connections are now persistent).

mongo.chunk_size int

The number of bytes-per-chunk. Used in divvying up GridFS files. This number must be at least 100 less than 4 megabytes (max: 4194204) and it is recommended that it be less than that.

mongo.cmd string

A character to be used in place of $ in modifiers and comparisons.

As it is easy to forget to escape the "$", you can also choose your own special character to use instead of '$'. Choose a character that will not occur in your key names, e.g. ":":

mongo.cmd = ":"

Then, to do a comparison, for example:

<?php

$query 
= array( "i" => array( ":gt" => 20":lte" => 30 ) );

?>

You can also change it in your code using ini_set("mongo.cmd", ":"). Of course, you can also just use single quotes or backslash-escape the $.

mongo.default_host string

Default hostname when nothing is passed to the constructor.

mongo.default_port string

The default TCP port number to use when connecting to the database server if no other port is specified. The database's default is 27017.

mongo.is_master_interval int

Added in version 1.2.10.

For replicaset connections: The minimum interval with which the driver will send "isMaster" requests to the MongoDB server. If the value is lower, there will be more requests, but the driver finds faster whether the topology of the replicaset has been changed.

mongo.long_as_object int

Return a BSON_LONG as an instance of MongoInt64 (instead of a primitive type).

mongo.native_long int

The default behavior for this has been changed to TRUE in 1.5.0, so make sure to set this variable to the value you want (probably TRUE) so that the driver's behavior doesn't suddenly change when you upgrade.

On 64-bit platforms, the mongo.native_long setting allows for 64-bit integers to be stored in MongoDB. If it is not set, only 32-bits of the integer will be saved. The MongoDB data type that is used in this case is the BSON LONG, instead of the BSON INT that is used if this setting is turned off.

The setting also changes the way how BSON LONGs behave when they are read back from MongoDB. Without mongo.native_long enabled, the driver would convert every BSON LONG to a PHP double which can result in a loss of precision.

On 32-bit platforms, the mongo.native_long setting changes nothing for storing integers in MongoDB: the integer is stored as a BSON INT as before. However, when the setting is enabled and a BSON LONG is read from MongoDB a MongoCursorException is thrown alerting you that the data could not be read back without losing precision.

On 32-bit systems especially, it is recommended that you combine this with enabling mongo.long_as_object.

mongo.ping_interval int

Added in version 1.2.10.

For replicaset connections: The minimum interval with which the driver will send "ping" requests to the MongoDB server. If the value is lower, there will be more pings, but the driver finds faster whether a node is no longer reachable from the replicaset.

mongo.utf8 int

If an exception should be thrown for non-UTF8 strings. Until version 1.0.4, the PHP driver would ignore non-UTF8 strings, even though you're not supposed to insert them. As of 1.0.4, the driver throws a MongoException. To ease the transition for applications that insert non-UTF8 strings, you can turn this option off to emulate the old, non-exception-throwning behavior. This option will be eliminated and exceptions always thrown for non-UTF8 strings starting with version 1.1.0.