PHP 클래스 MongoGridFS

상속: extends MongoCollection
파일 보기 프로젝트 열기: alcaeus/mongo-php-adapter 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$chunks MongoCollection

보호된 프로퍼티들

프로퍼티 타입 설명
$chunksName string
$filesName string

공개 메소드들

메소드 설명
__construct ( MongoDB $db, string $prefix = "fs", mixed $chunks = null ) Files as stored across two collections, the first containing file meta information, the second containing chunks of the actual file. By default, fs.files and fs.chunks are the collection names used.
__sleep ( ) : array
delete ( mixed $id ) : boolean Delete a file from the database
drop ( ) : array Drops the files and chunks collections
find ( array $query = [], array $fields = [] ) : MongoGridFSCursor
findOne ( mixed $query = [], array $fields = [], array $options = [] ) : MongoGridFSFile | null Returns a single file matching the criteria
get ( mixed $id ) : MongoGridFSFile | null Retrieve a file from the database
put ( string $filename, array $extra = [], array $options = [] ) : mixed Stores a file in the database
remove ( array $criteria = [], array $options = [] ) : boolean Removes files from the collections
storeBytes ( string $bytes, array $extra = [], array $options = [] ) : mixed Chunkifies and stores bytes in the database
storeFile ( string $filename, array $extra = [], array $options = [] ) : mixed Stores a file in the database
storeUpload ( string $name, array $metadata = [] ) : mixed Saves an uploaded file directly from a POST to the database

비공개 메소드들

메소드 설명
createChunksIndex ( ) Creates the index on the chunks collection
insertChunk ( mixed $fileId, string $data, integer $chunkNumber ) : array | boolean Inserts a single chunk into the database
insertChunksFromBytes ( string $bytes, array $record ) Splits a string into chunks and writes them to the database
insertChunksFromFile ( resource $handle, array $record, string &$md5 ) : integer Reads chunks from a file and writes them to the database
insertFile ( $record, array $options = [] ) : array Writes a file record to the database
isOKResult ( $result )

메소드 상세

__construct() 공개 메소드

Files as stored across two collections, the first containing file meta information, the second containing chunks of the actual file. By default, fs.files and fs.chunks are the collection names used.
public __construct ( MongoDB $db, string $prefix = "fs", mixed $chunks = null )
$db MongoDB Database
$prefix string [optional]

Optional collection name prefix.

$chunks mixed [optional]

__sleep() 공개 메소드

public __sleep ( ) : array
리턴 array

delete() 공개 메소드

Delete a file from the database
public delete ( mixed $id ) : boolean
$id mixed _id of the file to remove
리턴 boolean Returns true if the remove was successfully sent to the database.

drop() 공개 메소드

Drops the files and chunks collections
public drop ( ) : array
리턴 array The database response

find() 공개 메소드

public find ( array $query = [], array $fields = [] ) : MongoGridFSCursor
$query array The query
$fields array Fields to return
리턴 MongoGridFSCursor A MongoGridFSCursor

findOne() 공개 메소드

Returns a single file matching the criteria
public findOne ( mixed $query = [], array $fields = [], array $options = [] ) : MongoGridFSFile | null
$query mixed The fields for which to search or a filename to search for.
$fields array Fields of the results to return.
$options array Options for the find command
리턴 MongoGridFSFile | null

get() 공개 메소드

Retrieve a file from the database
public get ( mixed $id ) : MongoGridFSFile | null
$id mixed _id of the file to find.
리턴 MongoGridFSFile | null

put() 공개 메소드

Stores a file in the database
public put ( string $filename, array $extra = [], array $options = [] ) : mixed
$filename string The name of the file
$extra array Other metadata to add to the file saved
$options array An array of options for the insert operations executed against the chunks and files collections.
리턴 mixed Returns the _id of the saved object

remove() 공개 메소드

Removes files from the collections
public remove ( array $criteria = [], array $options = [] ) : boolean
$criteria array Description of records to remove.
$options array Options for remove.
리턴 boolean

storeBytes() 공개 메소드

Chunkifies and stores bytes in the database
public storeBytes ( string $bytes, array $extra = [], array $options = [] ) : mixed
$bytes string A string of bytes to store
$extra array Other metadata to add to the file saved
$options array Options for the store. "safe": Check that this store succeeded
리턴 mixed The _id of the object saved

storeFile() 공개 메소드

Stores a file in the database
public storeFile ( string $filename, array $extra = [], array $options = [] ) : mixed
$filename string The name of the file
$extra array Other metadata to add to the file saved
$options array Options for the store. "safe": Check that this store succeeded
리턴 mixed Returns the _id of the saved object

storeUpload() 공개 메소드

Saves an uploaded file directly from a POST to the database
public storeUpload ( string $name, array $metadata = [] ) : mixed
$name string The name attribute of the uploaded file, from .
$metadata array An array of extra fields for the uploaded file.
리턴 mixed Returns the _id of the uploaded file.

프로퍼티 상세

$chunks 공개적으로 프로퍼티

MongoCollection
public $chunks

$chunksName 보호되어 있는 프로퍼티

string
protected $chunksName

$filesName 보호되어 있는 프로퍼티

string
protected $filesName