<!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>The MongoException class</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongo.exceptions.html">Exceptions</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.mongoresultexception.html">MongoResultException</a></div> <div class="up"><a href="mongo.exceptions.html">Exceptions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="class.mongoexception" class="reference"> <h1 class="title">The MongoException class</h1> <div class="partintro"><p class="verinfo">(PECL mongo >= 1.0.0)</p> <div class="section" id="mongoexception.intro"> <h2 class="title">Introduction</h2> <p class="para"> Default Mongo exception. </p> <p class="para"> This covers a bunch of different error conditions that may eventually be moved to more specific exceptions, but will always extend <strong class="classname">MongoException</strong>. </p> <ul class="itemizedlist"> <li class="listitem"> <p class="para"> <em>The MongoSomething object has not been correctly initialized by its constructor</em> </p> <p class="para"> Code: 0 </p> <p class="para"> Probably your Mongo object is not connected to a database server. </p> </li> <li class="listitem"> <p class="para"> <em>zero-length keys are not allowed, did you use $ with double quotes?</em> </p> <p class="para"> Code: 1 </p> <p class="para"> You tried to save "" as a key. You generally should not do this. "" can mess up subobject access and is used by MongoDB internally. However, if you really want, you can set <a href="mongo.configuration.html#ini.mongo.allow-empty-keys" class="link">mongo.allow_empty_keys</a> to true in your php.ini file to override this sanity check. If you override this, it is highly recommended that you set error checking to strict to avoid string interpolation errors. </p> </li> <li class="listitem"> <p class="para"> <em>'.' not allowed in key: <key></em> </p> <p class="para"> Code: 2 </p> <p class="para"> You attempted to write a key with '.' in it, which is prohibited. </p> </li> <li class="listitem"> <p class="para"> <em>insert too large: <size>, max: <max></em> </p> <p class="para"> Code: 3 </p> <p class="para"> You're attempting to send too much data to the database at once: the database will only accept inserts up to a certain size (currently 16 MB). </p> </li> <li class="listitem"> <p class="para"> <em>no elements in doc</em> </p> <p class="para"> Code: 4 </p> <p class="para"> You're attempting to save a document with no fields. </p> </li> <li class="listitem"> <p class="para"> <em>size of BSON doc is <size> bytes, max <max>MB</em> </p> <p class="para"> Code: 5 </p> <p class="para"> You're attempting to save a document that is larger than MongoDB can save. </p> </li> <li class="listitem"> <p class="para"> <em>no documents given</em> </p> <p class="para"> Code: 6 </p> <p class="para"> You're attempting to batch insert an empty array of documents. </p> </li> <li class="listitem"> <p class="para"> <em>MongoCollection::group takes an array, object, or MongoCode key</em> </p> <p class="para"> Code: 7 </p> <p class="para"> Wrong type parameter send to <span class="function"><a href="mongocollection.group.html" class="function">MongoCollection::group()</a></span>. </p> </li> <li class="listitem"> <p class="para"> <em>field names must be strings</em> </p> <p class="para"> Code: 8 </p> <p class="para"> You should format field selectors as <em>array("field1" => 1, "field2" => 1, ..., "fieldN" => 1)</em>. </p> </li> <li class="listitem"> <p class="para"> <em>invalid regex</em> </p> <p class="para"> Code: 9 </p> <p class="para"> The regex passed to <a href="class.mongoregex.html" class="classname">MongoRegex</a> is not of the correct form. </p> </li> <li class="listitem"> <p class="para"> <em>MongoDBRef::get: $ref field must be a string</em> </p> <p class="para"> Code: 10 </p> </li> <li class="listitem"> <p class="para"> <em>MongoDBRef::get: $db field must be a string</em> </p> <p class="para"> Code: 11 </p> </li> <li class="listitem"> <p class="para"> <em>non-utf8 string: <str></em> </p> <p class="para"> Code: 12 </p> <p class="para"> This error occurs if you attempt to send a non-utf8 string to the database. All strings going into the database should be UTF8. See php.ini options for the transition option of quieting this exception. </p> </li> <li class="listitem"> <p class="para"> <em>mutex error: <err></em> </p> <p class="para"> Code: 13 </p> <p class="para"> The driver uses mutexes for synchronizing requests and responses in multithreaded environments. This is a fairly serious error and may not have a stack trace. It's unusual and should be reported to maintainers with any system information and steps to reproduce that you can provide. </p> </li> <li class="listitem"> <p class="para"> <em>index name too long: <len>, max <max> characters</em> </p> <p class="para"> Code: 14 </p> <p class="para"> Indexes with names longer than 128 characters cannot be created. If you get this error, you should use <span class="function"><a href="mongocollection.ensureindex.html" class="function">MongoCollection::ensureIndex()</a></span>'s "name" option to create a shorter name for your index. </p> </li> </ul> </div> <div class="section" id="mongoexception.synopsis"> <h2 class="title">Class synopsis</h2> <div class="classsynopsis"> <div class="ooclass"></div> <div class="classsynopsisinfo"> <span class="ooclass"> <strong class="classname">MongoException</strong> </span> <span class="ooclass"> <span class="modifier">extends</span> <a href="class.exception.html" class="classname">Exception</a> </span> {</div> }</div> </div> </div> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongo.exceptions.html">Exceptions</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.mongoresultexception.html">MongoResultException</a></div> <div class="up"><a href="mongo.exceptions.html">Exceptions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>