PHP Class Shanty_Mongo_Collection

Author: Coen Hyde
Show file Open project: coen-hyde/shanty-mongo Class Usage Examples

Protected Properties

Property Type Description
$_cachedCollectionInheritance
$_cachedCollectionRequirements
$_collection
$_connectionGroup
$_db
$_documentSetClass
$_requirements

Public Methods

Method Description
all ( array $query = [], array $fields = [] ) : Shanty_Mongo_Iterator_Cursor Find many documents
create ( array $data = [], boolean $new = true ) Create a new document belonging to this collection
deleteIndex ( string | array $keys ) Delete an index
deleteIndexes ( ) Remove all indexes from this collection
distinct ( String $property, $query = [] ) : array Select distinct values for a property
drop ( ) Drop this collection
ensureIndex ( array $keys, array $options = [] ) Ensure an index
fetchAll ( array $query = [], array $fields = [] ) : Shanty_Mongo_Iterator_Cursor Alias for all
fetchOne ( array $query = [], array $fields = [] ) : Shanty_Mongo_Document Alias for one
find ( MongoId | String $id, array $fields = [] ) : Shanty_Mongo_Document Find a document by id
getCollectionInheritance ( ) Get the inheritance of this collection
getCollectionName ( ) : string Get the name of the mongo collection
getCollectionRequirements ( bolean $inherited = true ) : array Get requirements
getConnection ( $writable = true ) * Get a connection
getConnectionGroupName ( ) : string Get the name of the connection group
getDbName ( ) : string Get the name of the mongo db
getDocumentClass ( ) : string Get the name of the document class
getDocumentSetClass ( ) : string Get the name of the document set class
getIndexInfo ( ) : array Get index information for this collection
getMongoCollection ( $writable = true ) : MongoCollection Get an instance of MongoCollection
getMongoDb ( $writable = true ) : MongoDb Get an instance of MongoDb
hasCollectionName ( ) : boolean Determine if this collection has a collection name set
hasDbName ( ) : boolean Determine if this collection has a database name set
insert ( array $document, array $options = [] ) Insert a document
insertBatch ( array $documents, array $options = [] ) Insert a batch of documents
isDocumentClass ( ) : boolean Is this class a document class
makeRequirementsTidy ( array $requirements ) : array Process requirements to make sure they are in the correct format
mergeRequirements ( $requirements1, $requirements2 ) : array Merge a two sets of requirements together
one ( array $query = [], array $fields = [] ) : Shanty_Mongo_Document Find one document
remove ( array $criteria, array $options = [] ) Remove documents from this collection
update ( array $criteria, array $object, array $options = [] ) Update documents from this collection

Method Details

all() public static method

Find many documents
public static all ( array $query = [], array $fields = [] ) : Shanty_Mongo_Iterator_Cursor
$query array
$fields array
return Shanty_Mongo_Iterator_Cursor

create() public static method

Create a new document belonging to this collection
public static create ( array $data = [], boolean $new = true )
$data array
$new boolean

deleteIndex() public static method

Delete an index
public static deleteIndex ( string | array $keys )
$keys string | array

deleteIndexes() public static method

Remove all indexes from this collection
public static deleteIndexes ( )

distinct() public static method

Select distinct values for a property
public static distinct ( String $property, $query = [] ) : array
$property String
return array

drop() public static method

Drop this collection
public static drop ( )

ensureIndex() public static method

Ensure an index
public static ensureIndex ( array $keys, array $options = [] )
$keys array
$options array

fetchAll() public static method

Alias for all
public static fetchAll ( array $query = [], array $fields = [] ) : Shanty_Mongo_Iterator_Cursor
$query array
$fields array
return Shanty_Mongo_Iterator_Cursor

fetchOne() public static method

Alias for one
public static fetchOne ( array $query = [], array $fields = [] ) : Shanty_Mongo_Document
$query array
$fields array
return Shanty_Mongo_Document

find() public static method

Find a document by id
public static find ( MongoId | String $id, array $fields = [] ) : Shanty_Mongo_Document
$id MongoId | String
$fields array
return Shanty_Mongo_Document

getCollectionInheritance() public static method

Get the inheritance of this collection
public static getCollectionInheritance ( )

getCollectionName() public static method

Get the name of the mongo collection
public static getCollectionName ( ) : string
return string

getCollectionRequirements() public static method

Get requirements
public static getCollectionRequirements ( bolean $inherited = true ) : array
$inherited bolean Include inherited requirements
return array

getConnection() public static method

* Get a connection
public static getConnection ( $writable = true )
$writable should the connection be writable

getConnectionGroupName() public static method

Get the name of the connection group
public static getConnectionGroupName ( ) : string
return string

getDbName() public static method

Get the name of the mongo db
public static getDbName ( ) : string
return string

getDocumentClass() public static method

Get the name of the document class
public static getDocumentClass ( ) : string
return string

getDocumentSetClass() public static method

Get the name of the document set class
public static getDocumentSetClass ( ) : string
return string

getIndexInfo() public static method

Get index information for this collection
public static getIndexInfo ( ) : array
return array

getMongoCollection() public static method

Get an instance of MongoCollection
public static getMongoCollection ( $writable = true ) : MongoCollection
return MongoCollection

getMongoDb() public static method

Get an instance of MongoDb
public static getMongoDb ( $writable = true ) : MongoDb
return MongoDb

hasCollectionName() public static method

Determine if this collection has a collection name set
public static hasCollectionName ( ) : boolean
return boolean

hasDbName() public static method

Determine if this collection has a database name set
public static hasDbName ( ) : boolean
return boolean

insert() public static method

Insert a document
public static insert ( array $document, array $options = [] )
$document array
$options array

insertBatch() public static method

Insert a batch of documents
public static insertBatch ( array $documents, array $options = [] )
$documents array
$options array

isDocumentClass() public static method

Is this class a document class
public static isDocumentClass ( ) : boolean
return boolean

makeRequirementsTidy() public static method

Process requirements to make sure they are in the correct format
public static makeRequirementsTidy ( array $requirements ) : array
$requirements array
return array

mergeRequirements() public static method

Merge a two sets of requirements together
public static mergeRequirements ( $requirements1, $requirements2 ) : array
return array

one() public static method

Find one document
public static one ( array $query = [], array $fields = [] ) : Shanty_Mongo_Document
$query array
$fields array
return Shanty_Mongo_Document

remove() public static method

Remove documents from this collection
public static remove ( array $criteria, array $options = [] )
$criteria array
$options array

update() public static method

Update documents from this collection
public static update ( array $criteria, array $object, array $options = [] )
$criteria array
$object array
$options array

Property Details

$_cachedCollectionInheritance protected static property

protected static $_cachedCollectionInheritance

$_cachedCollectionRequirements protected static property

protected static $_cachedCollectionRequirements

$_collection protected static property

protected static $_collection

$_connectionGroup protected static property

protected static $_connectionGroup

$_db protected static property

protected static $_db

$_documentSetClass protected static property

protected static $_documentSetClass

$_requirements protected static property

protected static $_requirements