<!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 MongoMinKey class</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongodbref.isref.html">MongoDBRef::isRef</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.mongomaxkey.html">MongoMaxKey</a></div> <div class="up"><a href="mongo.types.html">Types</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="class.mongominkey" class="reference"> <h1 class="title">The MongoMinKey class</h1> <div class="partintro"><p class="verinfo">(PECL mongo >= 1.0.2)</p> <div class="warning"><strong class="warning">Warning</strong> <p class="para">This extension that defines this class is deprecated. Instead, the <a href="set.mongodb.html" class="link">MongoDB</a> extension should be used. Alternatives to this class include:</p> <ul class="simplelist"> <li class="member"><a href="class.mongodb-bson-minkey.html" class="classname">MongoDB\BSON\MinKey</a></li> </ul> </div> <div class="section" id="mongominkey.intro"> <h2 class="title">Introduction</h2> <p class="para"> <strong class="classname">MongoMinKey</strong> is an special type used by the database that compares less than all other possible BSON values. Thus, if a query is sorted by a given field in ascending order, any document with a <strong class="classname">MongoMinKey</strong> as its value will be returned first. </p> <p class="para"> <strong class="classname">MongoMinKey</strong> has no associated fields, methods, or constants. It is merely the "smallest" value that can be represented in the database. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara"> <strong class="classname">MongoMinKey</strong> is used internally by MongoDB for indexing and sharding. There is generally no reason to use this class in an application. </span> </p></blockquote> </div> <div class="section" id="mongominkey.synopsis"> <h2 class="title">Class synopsis</h2> <div class="classsynopsis"> <div class="ooclass"></div> <div class="classsynopsisinfo"> <span class="ooclass"> <strong class="classname">MongoMinKey</strong> </span> {</div> }</div> </div> <div class="section" id="mongominkey.example"> <h2 class="title">Using <strong class="classname">MongoMinKey</strong> as a value</h2> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />$collection</span><span style="color: #007700">-></span><span style="color: #0000BB">insert</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"task" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"lunch"</span><span style="color: #007700">, </span><span style="color: #DD0000">"doBy" </span><span style="color: #007700">=> new </span><span style="color: #0000BB">MongoMinKey</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$collection</span><span style="color: #007700">-></span><span style="color: #0000BB">insert</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"task" </span><span style="color: #007700">=> </span><span style="color: #DD0000">"staff meeting"</span><span style="color: #007700">, </span><span style="color: #DD0000">"doBy" </span><span style="color: #007700">=> new </span><span style="color: #0000BB">MongoDate</span><span style="color: #007700">(</span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"+4 days"</span><span style="color: #007700">))));<br /><br /></span><span style="color: #0000BB">$cursor </span><span style="color: #007700">= </span><span style="color: #0000BB">$collection</span><span style="color: #007700">-></span><span style="color: #0000BB">find</span><span style="color: #007700">()-></span><span style="color: #0000BB">sort</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"doBy" </span><span style="color: #007700">=> </span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <p class="para"> The cursor will return the lunch document followed by the staff meeting document. The lunch document will always be returned first, regardless of what else is added to the collection (unless other documents are added with <strong class="classname">MongoMinKey</strong> in their "doBy" field). </p> </div> <div class="simplesect"> <h3 class="title">See Also</h3> <ul class="simplelist"> <li class="member"><a href="class.mongomaxkey.html" class="classname">MongoMaxKey</a></li> </ul> </div> </div> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongodbref.isref.html">MongoDBRef::isRef</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.mongomaxkey.html">MongoMaxKey</a></div> <div class="up"><a href="mongo.types.html">Types</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>