PHP 클래스 Sokil\Mongo\Document

저자: Dmytro Sokil ([email protected])
상속: extends Structure
파일 보기 프로젝트 열기: sokil/php-mongo 1 사용 예제들

공개 메소드들

메소드 설명
__call ( $name, $arguments )
__construct ( Collection $collection, array $data = null, array $options = [] )
__get ( $name )
__toString ( )
__unset ( $fieldName )
addRelation ( $relationName, Document $document )
addToSet ( $fieldName, $value )
addToSetEach ( $fieldName, array $values )
append ( type $selector, type $value ) : Structure If field not exist - set value.
attachBehavior ( string $name, string | array | Sokil\Mongo\Behavior $behavior ) : Document
attachBehaviors ( array $behaviors )
attachEvent ( string $event, callable | array | string $handler, $priority ) : Document Attach event handler
beforeConstruct ( ) Event handler, called before running constructor.
behaviors ( )
bitwiceAnd ( $field, $value )
bitwiceOr ( $field, $value )
bitwiceXor ( $field, $value )
clearBehaviors ( )
clearRevisions ( )
createReference ( ) : array Get reference to document
decrement ( $fieldName, $value = 1 )
defineId ( MongoId | string $id ) : Document Used to define id of stored document. This id must be already present in db
delete ( )
getCollection ( ) : Collection Get instance of collection
getId ( )
getOperator ( )
getOption ( $name, $default = null )
getOptions ( )
getReferencedDocument ( string $name ) : null | Document Get document by reference
getReferencedDocumentList ( string $name ) : null | Document Get document by reference
getRelated ( string $relationName ) : array | Document Get related documents
getRelationDefinition ( ) : array Relation definition through mapping is more prior to defined in class
getRevision ( $id )
getRevisionManager ( ) : Sokil\Mongo\RevisionManager
getRevisions ( $limit = null, $offset = null )
getRevisionsCount ( )
hasEvent ( string $event ) : boolean Check if event attached
hasOption ( $name )
increment ( $fieldName, $value = 1 )
isModificationOperatorDefined ( )
isSaveRequired ( )
isStored ( )
merge ( array $data ) : Document
pull ( integer | string | array | Expression | callable $expression, mixed | Expression | callable $value = null ) : Document Removes from an existing array all instances of a value or values that match a specified query
push ( string $fieldName, mixed $value ) : Document Push argument as single element to field value
pushEach ( string $fieldName, array $values ) : Document Push each element of argument's array as single element to field value
pushReference ( string $name, Document $document ) : Document Push reference to list
refresh ( ) Reload data from db and reset all unsaved data
removeRelation ( $relationName, Document $document = null )
reset ( ) : Document Reset all data passed to object in run-time, like events, behaviors, data modifications, etc. to the state just after open or save document
save ( $validate = true )
set ( string $fieldName, mixed $value ) : Document Update value in local cache and in DB
setGeometry ( string $field, GeoJson\Geometry\Geometry $geometry ) : Document Set geo data as GeoJson object
setGeometryCollection ( string $field, array $geometryCollection ) : Document Set collection of different geometries
setId ( MongoId | string $id ) : Document Used to define id of not stored document.
setLegacyPoint ( string $field, float $longitude, float $latitude ) : Document Set point as longitude and latitude in legacy format
setLineString ( string $field, array $pointArray ) : Document Set line string as array of points
setMultiLineString ( string $field, array $lineStringArray ) : Document Set multi line string as array of line strings
setMultiPoint ( string $field, array $pointArray ) : Document Set multi point as array of points
setMultyPolygon ( string $field, array $polygonsArray ) : Document Set multy polygon as array of polygons.
setPoint ( string $field, float $longitude, float $latitude ) : Document Set point as longitude and latitude
setPolygon ( string $field, array $lineRingsArray ) : Document Set polygon as array of line rings.
setReference ( $name, Document $document ) : Document Store DBRef to specified field
triggerEvent ( string $eventName, Event $event = null ) : Event Manually trigger defined events
unsetField ( string $fieldName ) : Document Remove field
validate ( ) : Document

보호된 메소드들

메소드 설명
relations ( ) : array Override in child class to define relations

비공개 메소드들

메소드 설명
getRelationManager ( ) : Sokil\Mongo\Document\RelationManager
initDelegates ( ) Initialise relative classes

메소드 상세

__call() 공개 메소드

public __call ( $name, $arguments )

__construct() 공개 메소드

public __construct ( Collection $collection, array $data = null, array $options = [] )
$collection Collection instance of Mongo collection
$data array mongo document
$options array options of object initialization

__get() 공개 메소드

public __get ( $name )

__toString() 공개 메소드

public __toString ( )

__unset() 공개 메소드

public __unset ( $fieldName )

addRelation() 공개 메소드

public addRelation ( $relationName, Document $document )
$document Document

addToSet() 공개 메소드

public addToSet ( $fieldName, $value )

addToSetEach() 공개 메소드

public addToSetEach ( $fieldName, array $values )
$values array

append() 공개 메소드

If field exists and is not array - convert to array and append If field -s array - append
public append ( type $selector, type $value ) : Structure
$selector type
$value type
리턴 Structure

attachBehavior() 공개 메소드

public attachBehavior ( string $name, string | array | Sokil\Mongo\Behavior $behavior ) : Document
$name string unique name of attached behavior
$behavior string | array | Sokil\Mongo\Behavior Behavior instance or behavior definition
리턴 Document

attachBehaviors() 공개 메소드

public attachBehaviors ( array $behaviors )
$behaviors array

attachEvent() 공개 메소드

Attach event handler
public attachEvent ( string $event, callable | array | string $handler, $priority ) : Document
$event string event name
$handler callable | array | string event handler
리턴 Document

beforeConstruct() 공개 메소드

May be overridden in child classes
public beforeConstruct ( )

behaviors() 공개 메소드

public behaviors ( )

bitwiceAnd() 공개 메소드

public bitwiceAnd ( $field, $value )

bitwiceOr() 공개 메소드

public bitwiceOr ( $field, $value )

bitwiceXor() 공개 메소드

public bitwiceXor ( $field, $value )

clearBehaviors() 공개 메소드

public clearBehaviors ( )

clearRevisions() 공개 메소드

사용 중단: since 1.13.0 use self::getRevisionManager()->clearRevisions()
public clearRevisions ( )

createReference() 공개 메소드

Get reference to document
public createReference ( ) : array
리턴 array

decrement() 공개 메소드

public decrement ( $fieldName, $value = 1 )

defineId() 공개 메소드

Used to define id of stored document. This id must be already present in db
public defineId ( MongoId | string $id ) : Document
$id MongoId | string id of document
리턴 Document

delete() 공개 메소드

public delete ( )

getCollection() 공개 메소드

Get instance of collection
public getCollection ( ) : Collection
리턴 Collection

getId() 공개 메소드

public getId ( )

getOperator() 공개 메소드

public getOperator ( )

getOption() 공개 메소드

public getOption ( $name, $default = null )

getOptions() 공개 메소드

public getOptions ( )

getReferencedDocument() 공개 메소드

Get document by reference
public getReferencedDocument ( string $name ) : null | Document
$name string name of field where reference stored
리턴 null | Document

getReferencedDocumentList() 공개 메소드

Get document by reference
public getReferencedDocumentList ( string $name ) : null | Document
$name string name of field where reference stored
리턴 null | Document

getRelated() 공개 메소드

Get related documents
public getRelated ( string $relationName ) : array | Document
$relationName string
리턴 array | Document related document or array of documents

getRelationDefinition() 공개 메소드

Relation definition through mapping is more prior to defined in class
public getRelationDefinition ( ) : array
리턴 array definition of relations

getRevision() 공개 메소드

사용 중단: since 1.13.0 use self::getRevisionManager()->getRevision()
public getRevision ( $id )

getRevisionManager() 공개 메소드

public getRevisionManager ( ) : Sokil\Mongo\RevisionManager
리턴 Sokil\Mongo\RevisionManager

getRevisions() 공개 메소드

사용 중단: since 1.13.0 use self::getRevisionManager()->getRevisions()
public getRevisions ( $limit = null, $offset = null )

getRevisionsCount() 공개 메소드

사용 중단: since 1.13.0 use self::getRevisionManager()->getRevisionsCount()
public getRevisionsCount ( )

hasEvent() 공개 메소드

Check if event attached
public hasEvent ( string $event ) : boolean
$event string event name
리턴 boolean

hasOption() 공개 메소드

public hasOption ( $name )

increment() 공개 메소드

public increment ( $fieldName, $value = 1 )

isModificationOperatorDefined() 공개 메소드

isSaveRequired() 공개 메소드

public isSaveRequired ( )

isStored() 공개 메소드

public isStored ( )

merge() 공개 메소드

public merge ( array $data ) : Document
$data array
리턴 Document

pull() 공개 메소드

Removes from an existing array all instances of a value or values that match a specified query
public pull ( integer | string | array | Expression | callable $expression, mixed | Expression | callable $value = null ) : Document
$expression integer | string | array | Expression | callable
$value mixed | Expression | callable
리턴 Document

push() 공개 메소드

Push argument as single element to field value
public push ( string $fieldName, mixed $value ) : Document
$fieldName string
$value mixed
리턴 Document

pushEach() 공개 메소드

Push each element of argument's array as single element to field value
public pushEach ( string $fieldName, array $values ) : Document
$fieldName string
$values array
리턴 Document

pushReference() 공개 메소드

Push reference to list
public pushReference ( string $name, Document $document ) : Document
$name string
$document Document
리턴 Document

refresh() 공개 메소드

Reload data from db and reset all unsaved data
public refresh ( )

relations() 보호된 메소드

Override in child class to define relations
protected relations ( ) : array
리턴 array relation description

removeRelation() 공개 메소드

public removeRelation ( $relationName, Document $document = null )
$document Document

reset() 공개 메소드

Reset all data passed to object in run-time, like events, behaviors, data modifications, etc. to the state just after open or save document
public reset ( ) : Document
리턴 Document

save() 공개 메소드

public save ( $validate = true )

set() 공개 메소드

Update value in local cache and in DB
public set ( string $fieldName, mixed $value ) : Document
$fieldName string point-delimited field name
$value mixed value to store
리턴 Document

setGeometry() 공개 메소드

Requires MongoDB version 2.4 or above with 2dsparse index version 1 to use Point, LineString and Polygon. Requires MongoDB version 2.6 or above with 2dsparse index version 2 to use MultiPoint, MultiLineString, MultiPolygon and GeometryCollection.
public setGeometry ( string $field, GeoJson\Geometry\Geometry $geometry ) : Document
$field string
$geometry GeoJson\Geometry\Geometry
리턴 Document

setGeometryCollection() 공개 메소드

Requires MongoDB version 2.6 or above with 2dsparse index version 2 to use MultiPoint, MultiLineString, MultiPolygon and GeometryCollection.
public setGeometryCollection ( string $field, array $geometryCollection ) : Document
$field string
$geometryCollection array
리턴 Document

setId() 공개 메소드

Used to define id of not stored document.
public setId ( MongoId | string $id ) : Document
$id MongoId | string id of document
리턴 Document

setLegacyPoint() 공개 메소드

May be used 2d index
public setLegacyPoint ( string $field, float $longitude, float $latitude ) : Document
$field string
$longitude float
$latitude float
리턴 Document

setLineString() 공개 메소드

Requires MongoDB version 2.4 or above with 2dsparse index version 1 to use Point, LineString and Polygon.
public setLineString ( string $field, array $pointArray ) : Document
$field string
$pointArray array array of points
리턴 Document

setMultiLineString() 공개 메소드

Requires MongoDB version 2.6 or above with 2dsparse index version 2 to use MultiPoint, MultiLineString, MultiPolygon and GeometryCollection. http://docs.mongodb.org/manual/core/2dsphere/#multilinestring
public setMultiLineString ( string $field, array $lineStringArray ) : Document
$field string
$lineStringArray array array of line strings
리턴 Document

setMultiPoint() 공개 메소드

Requires MongoDB version 2.6 or above with 2dsparse index version 2 to use MultiPoint, MultiLineString, MultiPolygon and GeometryCollection.
public setMultiPoint ( string $field, array $pointArray ) : Document
$field string
$pointArray array array of point arrays
리턴 Document

setMultyPolygon() 공개 메소드

Polygon is array of line rings. Line ring is closed line string (first and last point same). Line string is array of points. Requires MongoDB version 2.6 or above with 2dsparse index version 2 to use MultiPoint, MultiLineString, MultiPolygon and GeometryCollection.
public setMultyPolygon ( string $field, array $polygonsArray ) : Document
$field string
$polygonsArray array array of polygons
리턴 Document

setPoint() 공개 메소드

Requires MongoDB version 2.4 or above with 2dsparse index version 1 to use Point, LineString and Polygon.
public setPoint ( string $field, float $longitude, float $latitude ) : Document
$field string
$longitude float
$latitude float
리턴 Document

setPolygon() 공개 메소드

Line ring is closed line string (first and last point same). Line string is array of points. Requires MongoDB version 2.4 or above with 2dsparse index version 1 to use Point, LineString and Polygon.
public setPolygon ( string $field, array $lineRingsArray ) : Document
$field string
$lineRingsArray array array of line rings
리턴 Document

setReference() 공개 메소드

Store DBRef to specified field
public setReference ( $name, Document $document ) : Document
$name
$document Document
리턴 Document

triggerEvent() 공개 메소드

Manually trigger defined events
public triggerEvent ( string $eventName, Event $event = null ) : Event
$eventName string event name
$event Event
리턴 Event

unsetField() 공개 메소드

Remove field
public unsetField ( string $fieldName ) : Document
$fieldName string field name
리턴 Document

validate() 공개 메소드

public validate ( ) : Document
리턴 Document