<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Runtime Configuration</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongo.installation.html">Installation</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongo.manual.html">Manual</a></div> <div class="up"><a href="mongo.setup.html">Installing/Configuring</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mongo.configuration" class="section"> <h2 class="title">Runtime Configuration</h2> <p class="simpara"> The behaviour of these functions is affected by settings in <var class="filename">php.ini</var>. </p> <p class="para"> <table class="doctable table"> <caption><strong>Mongo Configure Options</strong></caption> <thead> <tr> <th>Name</th> <th>Default</th> <th>Changeable</th> <th>Changelog</th> </tr> </thead> <tbody class="tbody"> <tr> <td><a href="mongo.configuration.html#ini.mongo.allow-empty-keys" class="link">mongo.allow_empty_keys</a></td> <td>0</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="mongo.configuration.html#ini.mongo.allow-persistent" class="link">mongo.allow_persistent</a></td> <td>1</td> <td>PHP_INI_ALL</td> <td>Removed in 1.2.0</td> </tr> <tr> <td><a href="mongo.configuration.html#ini.mongo.chunk-size" class="link">mongo.chunk_size</a></td> <td>262144</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="mongo.configuration.html#ini.mongo.cmd" class="link">mongo.cmd</a></td> <td>"$"</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="mongo.configuration.html#ini.mongo.default-host" class="link">mongo.default_host</a></td> <td>"localhost"</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="mongo.configuration.html#ini.mongo.default-port" class="link">mongo.default_port</a></td> <td>27017</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="mongo.configuration.html#ini.mongo.is-master-interval" class="link">mongo.is_master_interval</a></td> <td>15</td> <td>PHP_INI_ALL</td> <td>Added in 1.2.10, before 1.3.0 the default value was 60.</td> </tr> <tr> <td><a href="mongo.configuration.html#ini.mongo.long-as-object" class="link">mongo.long_as_object</a></td> <td>0</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="mongo.configuration.html#ini.mongo.native-long" class="link">mongo.native_long</a></td> <td>0<a href="mongo.configuration.html#ini.mongo.native-long" class="link">*</a></td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr> <td><a href="mongo.configuration.html#ini.mongo.ping-interval" class="link">mongo.ping_interval</a></td> <td>5</td> <td>PHP_INI_ALL</td> <td>Added in 1.2.10</td> </tr> <tr> <td><a href="mongo.configuration.html#ini.mongo.utf8" class="link">mongo.utf8</a></td> <td>1</td> <td>PHP_INI_ALL</td> <td class="empty"> </td> </tr> </tbody> </table> For further details and definitions of the PHP_INI_* modes, see the <a href="configuration.changes.modes.html" class="xref">Where a configuration setting may be set</a>. </p> <p class="para">Here's a short explanation of the configuration directives.</p> <p class="para"> <dl> <dt id="ini.mongo.allow-empty-keys"> <span class="term"> <em><code class="parameter">mongo.allow_empty_keys</code></em> <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> </span> <dd> <p class="para"> Added in version 1.0.11. </p> <p class="para"> 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. </p> </dd> </dt> <dt id="ini.mongo.allow-persistent"> <span class="term"> <em><code class="parameter">mongo.allow_persistent</code></em> <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> </span> <dd> <p class="para"> If persistent connections are allowed. (Removed in 1.2.0 - all connections are now persistent). </p> </dd> </dt> <dt id="ini.mongo.chunk-size"> <span class="term"> <em><code class="parameter">mongo.chunk_size</code></em> <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> </span> <dd> <p class="para"> 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. </p> </dd> </dt> <dt id="ini.mongo.cmd"> <span class="term"> <em><code class="parameter">mongo.cmd</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> A character to be used in place of $ in modifiers and comparisons. </p> <p class="para"> 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. ":": </p> <div class="example-contents"> <div class="cdata"><pre> mongo.cmd = ":" </pre></div> </div> <p class="para"> Then, to do a comparison, for example: </p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />$query </span><span style="color: #007700">= array( </span><span style="color: #DD0000">"i" </span><span style="color: #007700">=> array( </span><span style="color: #DD0000">":gt" </span><span style="color: #007700">=> </span><span style="color: #0000BB">20</span><span style="color: #007700">, </span><span style="color: #DD0000">":lte" </span><span style="color: #007700">=> </span><span style="color: #0000BB">30 </span><span style="color: #007700">) );<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <p class="para"> You can also change it in your code using <em>ini_set("mongo.cmd", ":")</em>. Of course, you can also just use single quotes or backslash-escape the $. </p> </dd> </dt> <dt id="ini.mongo.default-host"> <span class="term"> <em><code class="parameter">mongo.default_host</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> Default hostname when nothing is passed to the constructor. </p> </dd> </dt> <dt id="ini.mongo.default-port"> <span class="term"> <em><code class="parameter">mongo.default_port</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span> </span> <dd> <p class="para"> The default TCP port number to use when connecting to the database server if no other port is specified. The database's default is <em>27017</em>. </p> </dd> </dt> <dt id="ini.mongo.is-master-interval"> <span class="term"> <em><code class="parameter">mongo.is_master_interval</code></em> <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> </span> <dd> <p class="para"> Added in version 1.2.10. </p> <p class="para"> 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. </p> </dd> </dt> <dt id="ini.mongo.long-as-object"> <span class="term"> <em><code class="parameter">mongo.long_as_object</code></em> <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> </span> <dd> <p class="para"> Return a BSON_LONG as an instance of <a href="class.mongoint64.html" class="classname">MongoInt64</a> (instead of a primitive type). </p> </dd> </dt> <dt id="ini.mongo.native-long"> <span class="term"> <em><code class="parameter">mongo.native_long</code></em> <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> </span> <dd> <p class="para"> <em class="emphasis"> The default behavior for this will be changed to <strong><code>TRUE</code></strong> in 2.0.0, so make sure to set this variable to the value you want (probably <strong><code>TRUE</code></strong>) so that the driver's behavior doesn't suddenly change when you upgrade. </em> </p> <p class="para"> On 64-bit platforms, the <em>mongo.native_long</em> 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. </p> <p class="para"> The setting also changes the way how BSON LONGs behave when they are read back from MongoDB. Without <em>mongo.native_long</em> enabled, the driver would convert every BSON LONG to a PHP double which can result in a loss of precision. </p> <p class="para"> On 32-bit platforms, the <em>mongo.native_log</em> 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 <a href="class.mongocursorexception.html" class="classname">MongoCursorException</a> is thrown alerting you that the data could not be read back without losing precision. </p> <p class="para"> On 32-bit systems especially, it is recommended that you combine this with enabling <em>mongo.long_as_object</em>. </p> </dd> </dt> <dt id="ini.mongo.ping-interval"> <span class="term"> <em><code class="parameter">mongo.ping_interval</code></em> <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> </span> <dd> <p class="para"> Added in version 1.2.10. </p> <p class="para"> 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. </p> </dd> </dt> <dt id="ini.mongo.utf8"> <span class="term"> <em><code class="parameter">mongo.utf8</code></em> <span class="type"><a href="language.types.integer.html" class="type int">int</a></span> </span> <dd> <p class="para"> 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 <a href="class.mongoexception.html" class="classname">MongoException</a>. 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. </p> </dd> </dt> </dl> </p> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongo.installation.html">Installation</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongo.manual.html">Manual</a></div> <div class="up"><a href="mongo.setup.html">Installing/Configuring</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>