Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mongogridfs.storebytes(3) [php man page]

MONGOGRIDFS.STOREBYTES(3)						 1						 MONGOGRIDFS.STOREBYTES(3)

MongoGridFS::storeBytes - Stores a string of bytes in the database

SYNOPSIS
public mixed MongoGridFS::storeBytes (string $bytes, [array $metadata = array()], [array $options = array()]) DESCRIPTION
PARAMETERS
o $bytes - String of bytes to store. o $metadata - Other metadata fields to include in the file document. Note These fields may also overwrite those that would be created automatically by the driver, as described in the MongoDB core documentation for the files collection. Some practical use cases for this behavior would be to specify a custom chunkSize or _id for the file. o $options - An array of options for the insert operations executed against the chunks and files collections. See MongoCollection.insert(3) for documentation on these these options. RETURN VALUES
Returns the _id of the saved file document. This will be a generated MongoId unless an _id was explicitly specified in the $metadata param- eter. ERRORS
/EXCEPTIONS Throws MongoGridFSException if there is an error inserting into the chunks or files collections. EXAMPLES
Example #1 MongoGridFS.storeBytes(3) with additional metadata <?php $m = new MongoClient(); $gridfs = $m->selectDB('test')->getGridFS(); $bytes = 'abcdefghijklmnopqrstuvwxyz'; $id = $gridfs->storeBytes($bytes, array('_id' => 'alphabet')); $gridfsFile = $gridfs->get($id); var_dump($gridfsFile->file); ?> The above example will output something similar to: array(7) { ["_id"]=> string(8) "alphabet" ["uploadDate"]=> object(MongoDate)#7(0) { } ["length"]=> int(26) ["chunkSize"]=> int(262144) ["md5"]=> string(32) "c3fcd3d76192e4007dfb496cca67e13b" } SEE ALSO
MongoGridFS.put(3), MongoGridFS.storeFile(3), MongoGridFS.storeUpload(3), MongoDB core docs on GridFS. PHP Documentation Group MONGOGRIDFS.STOREBYTES(3)

Check Out this Related Man Page

MONGOID(3)								 1								MONGOID(3)

The MongoId class

INTRODUCTION
A unique identifier created for database objects. If an object is inserted into the database without an _id field, an _id field will be added to it with a MongoId instance as its value. If the data has a naturally occuring unique field (e.g. username or timestamp) it is fine to use this as the _id field instead, and it will not be replaced with a MongoId. Instances of the MongoId class fulfill the role that autoincrementing does in a relational database: to provide a unique key if the data does not natually have one. Autoincrementing does not work well with a sharded database, as it is difficult to determine the next number in the sequence. This class fulfills the constraints of quickly generating a value that is unique across shards. Each MongoId is 12 bytes (making its string form 24 hexadecimal characters). The first four bytes are a timestamp, the next three are a hash of the client machine's hostname, the next two are the two least significant bytes of the process id running the script, and the last three bytes are an incrementing value. MongoIds are serializable/unserializable. Their serialized form is similar to their string form: C:7:"MongoId":24:{4af9f23d8ead0e1d32000000} CLASS SYNOPSIS
MongoId MongoId o public string$id NULL Methods o public MongoId::__construct NULL ([string|MongoId $id]) o publicstatic string MongoId::getHostname (void ) o public int MongoId::getInc (void ) o public int MongoId::getPID (void ) o public int MongoId::getTimestamp (void ) o publicstatic bool MongoId::isValid (mixed $value) o publicstatic MongoId MongoId::__set_state (array $props) o public string MongoId::__toString (void ) FIELDS
o $id - This field contains the string representation of this object. Note The property name begins with a $ character. It may be accessed using complex variable parsed syntax (e.g. $mon- goId->{'$id'}). SEE ALSO
MongoDB core docs on ObjectIds. PHP Documentation Group MONGOID(3)
Man Page