Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

hw_incollections(3) [php man page]

HW_INCOLLECTIONS(3)							 1						       HW_INCOLLECTIONS(3)

hw_InCollections - Check if object ids in collections

SYNOPSIS
array hw_incollections (int $connection, array $object_id_array, array $collection_id_array, int $return_collections) DESCRIPTION
Checks whether a set of objects (documents or collections) specified by the $object_id_array is part of the collections listed in $collec- tion_id_array. PARAMETERS
o $connection - The connection identifier. o $object_id_array - An array of object ids. o $collection_id_array - An array of collection ids. o $return_collections - When set to 0, the subset of object ids that is part of the collections (i.e., the documents or collections that are children of one or more collections of collection ids or their subcollections, recursively) is returned as an array. When set to 1, the set of collections that have one or more objects of this subset as children are returned as an array. This option allows a client to, e.g., highlight the part of the collection hierarchy that contains the matches of a previous query, in a graphical overview. RETURN VALUES
Returns an array of object ids. PHP Documentation Group HW_INCOLLECTIONS(3)

Check Out this Related Man Page

MONGODBREF(3)								 1							     MONGODBREF(3)

The MongoDBRef class

INTRODUCTION
This class can be used to create lightweight links between objects in different collections. Motivation: Suppose we need to refer to a document in another collection. The easiest way is to create a field in the current document. For example, if we had a "people" collection and an "addresses" collection, we might want to create a link between each person document and an address document: Example #1 Linking documents <?php $people = $db->people; $addresses = $db->addresses; $myAddress = array("line 1" => "123 Main Street", "line 2" => null, "city" => "Springfield", "state" => "Vermont", "country" => "USA"); // save the address $addresses->insert($myAddress); // save a person with a reference to the address $me = array("name" => "Fred", "address" => $myAddress['_id']); $people->insert($me); ?> Then, later on, we can find the person's address by querying the "addresses" collection with the MongoId we saved in the "people" collec- tion. Suppose now that we have a more general case, where we don't know which collection (or even which database) contains the referenced docu- ment. MongoDBRef is a good choice for this case, as it is a common format that all of the drivers and the database understand. If each person had a list of things they liked which could come from multiple collections, such as "hobbies", "sports", "books", etc., we could use MongoDBRefs to keep track of what "like" went with what collection: Example #2 Creating MongoDBRef links <?php $people = $db->selectCollection("people"); // model trains are in the "hobbies" collection $trainRef = MongoDBRef::create("hobbies", $modelTrains['_id']); // soccer is in the "sports" collection $soccerRef = MongoDBRef::create("sports", $soccer['_id']); // now we'll know what collections the items in the "likes" array came from when // we retrieve this document $people->insert(array("name" => "Fred", "likes" => array($trainRef, $soccerRef))); ?> Database references can be thought of as hyperlinks: they give the unique address of another document, but they do not load it or automat- ically follow the link/reference. A database reference is just a normal associative array, not an instance of MongoDBRef, so this class is a little different than the other data type classes. This class contains exclusively static methods for manipulating database references. CLASS SYNOPSIS
MongoDBRef MongoDBRef Methods o publicstatic array MongoDBRef::create (string $collection, mixed $id, [string $database]) o publicstatic array MongoDBRef::get (MongoDB $db, array $ref) o publicstatic bool MongoDBRef::isRef (mixed $ref) SEE ALSO
MongoDB core docs on databases references. PHP Documentation Group MONGODBREF(3)
Man Page