本文整理汇总了PHP中Doctrine\ODM\MongoDB\MongoDBException::shardKeyFieldMissing方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoDBException::shardKeyFieldMissing方法的具体用法?PHP MongoDBException::shardKeyFieldMissing怎么用?PHP MongoDBException::shardKeyFieldMissing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\MongoDB\MongoDBException
的用法示例。
在下文中一共展示了MongoDBException::shardKeyFieldMissing方法的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());
}
}