shardKeyFieldMissing() public static method

public static shardKeyFieldMissing ( string $field, string $className ) : MongoDBException
$field string
$className string
return MongoDBException
Exemplo n.º 1
0
 /**
  * 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());
     }
 }