downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

MongoBinData::__construct> <MongoRegex::__toString
Last updated: Fri, 20 Nov 2009

view this page in

The MongoBinData class

Wstęp

An object that can be used to store or retrieve binary data from the database.

The maximum size of a single object that can be inserted into the database is 4Mb. For data that is larger than this (movies, music, Henry Kissinger's autobiography), use MongoGridFS. For data that is smaller than 4Mb, it's probably be easier to just embed it into the document using MongoBinData.

For example, to embed an image in a document, one could write:

<?php

$profile 
= array("username" => "foobity",
    
"pic" => new MongoBinData(get_file_contents("gravatar.jpg"));

$users->save($profile);

?>

This class contains a type field, which is currently gives no additional functionality in the driver or the database. There are five predefined types (which are the class constants listed below), and the user can create their own (at the risk of the BSON spec catching up with them). By default, the PHP driver always uses type 2: a byte array.

Krótki opis klasy

MongoBinData
MongoBinData {
/* Constants */
int $FUNC = 1 ;
int $BYTE_ARRAY = 2 ;
int $UUID = 3 ;
int $MD5 = 5 ;
int $CUSTOM = 128 ;
/* Fields */
public string $bin ;
public int $type = 2 ;
/* Methods */
public __construct ( string $data [, int $type ] )
public string __toString ( void )
}

Spis treści



add a note add a note User Contributed Notes
MongoBinData
There are no user contributed notes for this page.

MongoBinData::__construct> <MongoRegex::__toString
Last updated: Fri, 20 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites