当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMetadataInfo::setShardKey方法代码示例

本文整理汇总了PHP中Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo::setShardKey方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadataInfo::setShardKey方法的具体用法?PHP ClassMetadataInfo::setShardKey怎么用?PHP ClassMetadataInfo::setShardKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo的用法示例。


在下文中一共展示了ClassMetadataInfo::setShardKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setShardKey

 /**
  * @param ClassMetadataInfo $class
  * @param ODM\ShardKey      $shardKey
  *
  * @throws MappingException
  */
 private function setShardKey(ClassMetadataInfo $class, ODM\ShardKey $shardKey)
 {
     $options = array();
     $allowed = array('unique', 'numInitialChunks');
     foreach ($allowed as $name) {
         if (isset($shardKey->{$name})) {
             $options[$name] = $shardKey->{$name};
         }
     }
     $class->setShardKey($shardKey->keys, $options);
 }
开发者ID:doctrine,项目名称:mongodb-odm,代码行数:17,代码来源:AnnotationDriver.php

示例2: setShardKey

 private function setShardKey(ClassMetadataInfo $class, \SimpleXmlElement $xmlShardkey)
 {
     $attributes = $xmlShardkey->attributes();
     $keys = array();
     $options = array();
     foreach ($xmlShardkey->{'key'} as $key) {
         $keys[(string) $key['name']] = isset($key['order']) ? (string) $key['order'] : 'asc';
     }
     if (isset($attributes['unique'])) {
         $options['unique'] = 'true' === (string) $attributes['unique'];
     }
     if (isset($attributes['numInitialChunks'])) {
         $options['numInitialChunks'] = (int) $attributes['numInitialChunks'];
     }
     if (isset($xmlShardkey->{'option'})) {
         foreach ($xmlShardkey->{'option'} as $option) {
             $value = (string) $option['value'];
             if ($value === 'true') {
                 $value = true;
             } elseif ($value === 'false') {
                 $value = false;
             } elseif (is_numeric($value)) {
                 $value = preg_match('/^[-]?\\d+$/', $value) ? (int) $value : (double) $value;
             }
             $options[(string) $option['name']] = $value;
         }
     }
     $class->setShardKey($keys, $options);
 }
开发者ID:briareos,项目名称:mongodb-odm,代码行数:29,代码来源:XmlDriver.php

示例3: testNoReferenceManyInShardKey

 /**
  * @expectedException \Doctrine\ODM\MongoDB\Mapping\MappingException
  * @expectedExceptionMessage No multikey indexes are allowed in the shard key
  */
 public function testNoReferenceManyInShardKey()
 {
     $cm = new ClassMetadataInfo('stdClass');
     $cm->mapManyEmbedded(['fieldName' => 'referenceMany']);
     $cm->setShardKey(array('referenceMany' => 1));
 }
开发者ID:alcaeus,项目名称:mongodb-odm,代码行数:10,代码来源:ClassMetadataInfoTest.php

示例4: setShardKey

 private function setShardKey(ClassMetadataInfo $class, array $shardKey)
 {
     $keys = $shardKey['keys'];
     $options = array();
     if (isset($shardKey['options'])) {
         $allowed = array('unique', 'numInitialChunks');
         foreach ($shardKey['options'] as $name => $value) {
             if (!in_array($name, $allowed, true)) {
                 continue;
             }
             $options[$name] = $value;
         }
     }
     $class->setShardKey($keys, $options);
 }
开发者ID:doctrine,项目名称:mongodb-odm,代码行数:15,代码来源:YamlDriver.php

示例5: testEmbeddedDocumentCantHaveShardKey

 /**
  * @expectedException \Doctrine\ODM\MongoDB\Mapping\MappingException
  * @expectedExceptionMessage Embedded document can't have shard key: stdClass
  */
 public function testEmbeddedDocumentCantHaveShardKey()
 {
     $cm = new ClassMetadataInfo('stdClass');
     $cm->isEmbeddedDocument = true;
     $cm->setShardKey(array('id' => 'asc'));
 }
开发者ID:briareos,项目名称:mongodb-odm,代码行数:10,代码来源:ClassMetadataInfoTest.php


注:本文中的Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo::setShardKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。