本文整理汇总了PHP中Doctrine\ODM\MongoDB\MongoDBException::documentNotMappedToCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoDBException::documentNotMappedToCollection方法的具体用法?PHP MongoDBException::documentNotMappedToCollection怎么用?PHP MongoDBException::documentNotMappedToCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\MongoDB\MongoDBException
的用法示例。
在下文中一共展示了MongoDBException::documentNotMappedToCollection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDocumentCollection
/**
* Returns the MongoCollection instance for a class.
*
* @param string $className The class name.
* @return Doctrine\ODM\MongoDB\MongoCollection
*/
public function getDocumentCollection($className)
{
$metadata = $this->_metadataFactory->getMetadataFor($className);
$collection = $metadata->getCollection();
$db = $metadata->getDB();
$key = $db . '.' . $collection;
if ($collection && !isset($this->_documentCollections[$key])) {
if ($metadata->isFile()) {
$collection = $this->getDocumentDB($className)->getGridFS($collection);
} else {
$collection = $this->getDocumentDB($className)->selectCollection($collection);
}
$mongoCollection = new MongoCollection($collection, $metadata, $this);
$this->_documentCollections[$key] = $mongoCollection;
}
if (!isset($this->_documentCollections[$key])) {
throw MongoDBException::documentNotMappedToCollection($className);
}
return $this->_documentCollections[$key];
}
示例2: getDocumentCollection
/**
* Returns the MongoCollection instance for a class.
*
* @param string $className The class name.
* @return Doctrine\MongoDB\Collection
*/
public function getDocumentCollection($className)
{
$metadata = $this->metadataFactory->getMetadataFor($className);
$db = $metadata->getDatabase();
$collection = $metadata->getCollection();
if (!$collection) {
throw MongoDBException::documentNotMappedToCollection($className);
}
$db = $this->getDocumentDatabase($className);
if ($metadata->isFile()) {
$collection = $db->getGridFS($collection);
} else {
$collection = $db->selectCollection($collection);
}
return $collection;
}
示例3: getDocumentCollection
/**
* Returns the MongoCollection instance for a class.
*
* @param string $className The class name.
* @return \Doctrine\MongoDB\Collection
*/
public function getDocumentCollection($className)
{
$metadata = $this->metadataFactory->getMetadataFor($className);
$collection = $metadata->getCollection();
if (!$collection) {
throw MongoDBException::documentNotMappedToCollection($className);
}
$db = $this->getDocumentDatabase($className);
if (!isset($this->documentCollections[$className])) {
if ($metadata->isFile()) {
$this->documentCollections[$className] = $db->getGridFS($collection);
} else {
$this->documentCollections[$className] = $db->selectCollection($collection);
}
}
$collection = $this->documentCollections[$className];
if (isset($metadata->slaveOkay)) {
$collection->setSlaveOkay($metadata->slaveOkay);
}
return $this->documentCollections[$className];
}
示例4: getDocumentCollection
/**
* Returns the MongoCollection instance for a class.
*
* @param string $className The class name.
* @throws MongoDBException When the $className param is not mapped to a collection
* @return \Doctrine\MongoDB\Collection
*/
public function getDocumentCollection($className)
{
$className = ltrim($className, '\\');
$metadata = $this->metadataFactory->getMetadataFor($className);
$collectionName = $metadata->getCollection();
if (!$collectionName) {
throw MongoDBException::documentNotMappedToCollection($className);
}
if (!isset($this->documentCollections[$className])) {
$db = $this->getDocumentDatabase($className);
$this->documentCollections[$className] = $metadata->isFile() ? $db->getGridFS($collectionName) : $db->selectCollection($collectionName);
}
$collection = $this->documentCollections[$className];
if ($metadata->slaveOkay !== null) {
$collection->setSlaveOkay($metadata->slaveOkay);
}
return $this->documentCollections[$className];
}