Php/docs/class.mongocollection
(PECL mongo >=0.9.0)
简介
Represents a MongoDB collection.
Collection names can use any character in the ASCII set. Some valid collection names are "", "...", "my collection", and "*&#@".
User-defined collection names cannot contain the $ symbol. There are certain system collections which use a $ in their names (e.g., local.oplog.$main), but it is a reserved character. If you attempt to create and use a collection with a $ in the name, MongoDB will assert.
类摘要
MongoCollection {
const
int
ASCENDING
= 1
const
int
DESCENDING
= -1
/* Fields */
public
MongoDB
$db
= null
public
int
$w
public
int
$wtimeout
/* 方法 */
public aggregate
( array $pipeline
[, array $options
] ) : array
public aggregateCursor
( array $command
[, array $options
] ) : MongoCommandCursor
public batchInsert
( array $a
[, array $options
= array()
] ) : mixed
public __construct
( MongoDB $db
, string $name
)
public count
([ array $query
= array()
[, int $limit
= 0
[, int $skip
= 0
]]] ) : int
public createDBRef
( mixed $document_or_id
) : array
public createIndex
( array $keys
[, array $options
= array()
] ) : bool
public deleteIndex
( string|array $keys
) : array
public deleteIndexes ( ) : array
public distinct
( string $key
[, array $query
] ) : array
public drop ( ) : array
public ensureIndex
( string|array $key|keys
[, array $options
= array()
] ) : bool
public find
([ array $query
= array()
[, array $fields
= array()
]] ) : MongoCursor
public findAndModify
( array $query
[, array $update
[, array $fields
[, array $options
]]] ) : array
public findOne
([ array $query
= array()
[, array $fields
= array()
[, array $options
= array()
]]] ) : array
public __get
( string $name
) : MongoCollection
public getDBRef
( array $ref
) : array
public getIndexInfo ( ) : array
public getName ( ) : string
public getReadPreference ( ) : array
public getSlaveOkay ( ) : bool
public getWriteConcern ( ) : array
public group
( mixed $keys
, array $initial
, MongoCode $reduce
[, array $options
= array()
] ) : array
public insert
( array|object $a
[, array $options
= array()
] ) : bool|array
public parallelCollectionScan
( int $num_cursors
) : array[MongoCommandCursor]
public remove
([ array $criteria
= array()
[, array $options
= array()
]] ) : bool|array
public setReadPreference
( string $read_preference
[, array $tags
] ) : bool
public setSlaveOkay
([ bool $ok
= true
] ) : bool
public setWriteConcern
( mixed $w
[, int $wtimeout
] ) : bool
static protected toIndexString
( mixed $keys
) : string
public __toString ( ) : string
public update
( array $criteria
, array $new_object
[, array $options
= array()
] ) : bool|array
public validate
([ bool $scan_data
= false
] ) : array
}
预定义常量
MongoCollection::ASCENDING
- Ascending direction for sorts and index creation.
MongoCollection::DESCENDING
- Descending direction for sorts and index creation.
Fields
db
- The "parent" database for this collection.
w
- The number of servers to replicate a change to before returning success. Value is inherited from the parent database. The MongoDB class has a more detailed description of how
w
works. wtimeout
- The number of milliseconds to wait for
$this->w
replications to take place. Value is inherited from the parent database. The MongoDB class has a more detailed description of howwtimeout
works.
Table of Contents
- MongoCollection::aggregate — Perform an aggregation using the aggregation framework
- MongoCollection::aggregateCursor — Execute an aggregation pipeline command and retrieve results through a cursor
- MongoCollection::batchInsert — Inserts multiple documents into this collection
- MongoCollection::__construct — 创建一个新的集合
- MongoCollection::count — 返回集合中的文档数量
- MongoCollection::createDBRef — 创建一个数据库引用
- MongoCollection::createIndex — Creates an index on the specified field(s) if it does not already exist
- MongoCollection::deleteIndex — Deletes an index from this collection
- MongoCollection::deleteIndexes — 删除集合的所有索引
- MongoCollection::distinct — 获取集合里指定键的不同值的列表。
- MongoCollection::drop — 删除该集合
- MongoCollection::ensureIndex — Creates an index on the specified field(s) if it does not already exist
- MongoCollection::find — 查询该集合,并返回结果集的 MongoCursor
- MongoCollection::findAndModify — Update a document and return it
- MongoCollection::findOne — Queries this collection, returning a single element
- MongoCollection::__get — Gets a collection
- MongoCollection::getDBRef — Fetches the document pointed to by a database reference
- MongoCollection::getIndexInfo — Returns information about indexes on this collection
- MongoCollection::getName — 返回这个集合的名称
- MongoCollection::getReadPreference — Get the read preference for this collection
- MongoCollection::getSlaveOkay — Get slaveOkay setting for this collection
- MongoCollection::getWriteConcern — Get the write concern for this collection
- MongoCollection::group — Performs an operation similar to SQL's GROUP BY command
- MongoCollection::insert — 插入文档到集合中
- MongoCollection::parallelCollectionScan — Returns an array of cursors to iterator over a full collection in parallel
- MongoCollection::remove — 从集合中删除记录
- MongoCollection::save — 保存一个文档到集合
- MongoCollection::setReadPreference — Set the read preference for this collection
- MongoCollection::setSlaveOkay — Change slaveOkay setting for this collection
- MongoCollection::setWriteConcern — Set the write concern for this database
- MongoCollection::toIndexString — Converts keys specifying an index to its identifying string
- MongoCollection::__toString — String representation of this collection
- MongoCollection::update — Update records based on a given criteria
- MongoCollection::validate — Validates this collection
/* 常量 */