本文整理汇总了PHP中Doctrine\ODM\MongoDB\Mapping\ClassMetadata::getFieldMappingByDbFieldName方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::getFieldMappingByDbFieldName方法的具体用法?PHP ClassMetadata::getFieldMappingByDbFieldName怎么用?PHP ClassMetadata::getFieldMappingByDbFieldName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\MongoDB\Mapping\ClassMetadata
的用法示例。
在下文中一共展示了ClassMetadata::getFieldMappingByDbFieldName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guardMissingShardKey
/**
* If the document is new, ignore shard key field value, otherwise throw an exception.
* Also, shard key field should be present in actual document data.
*
* @param object $document
* @param string $shardKeyField
* @param array $actualDocumentData
*
* @throws MongoDBException
*/
private function guardMissingShardKey($document, $shardKeyField, $actualDocumentData)
{
$dcs = $this->uow->getDocumentChangeSet($document);
$isUpdate = $this->uow->isScheduledForUpdate($document);
$fieldMapping = $this->class->getFieldMappingByDbFieldName($shardKeyField);
$fieldName = $fieldMapping['fieldName'];
if ($isUpdate && isset($dcs[$fieldName]) && $dcs[$fieldName][0] != $dcs[$fieldName][1]) {
throw MongoDBException::shardKeyFieldCannotBeChanged($shardKeyField, $this->class->getName());
}
if (!isset($actualDocumentData[$fieldName])) {
throw MongoDBException::shardKeyFieldMissing($shardKeyField, $this->class->getName());
}
}