• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP MongoDB\MongoDBException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: convertToDatabaseValue

 public function convertToDatabaseValue($value)
 {
     if ($value !== null && !is_array($value)) {
         throw MongoDBException::invalidValueForType('Hash', array('array', 'null'), $value);
     }
     return $value !== null ? (object) $value : null;
 }
开发者ID:alcaeus,项目名称:mongodb-odm,代码行数:7,代码来源:HashType.php


示例2: convertToDatabaseValue

 public function convertToDatabaseValue($value)
 {
     if ($value !== null && !is_array($value)) {
         throw MongoDBException::invalidValueForType('Collection', array('array', 'null'), $value);
     }
     return $value !== null ? array_values($value) : null;
 }
开发者ID:alcaeus,项目名称:mongodb-odm,代码行数:7,代码来源:CollectionType.php


示例3: getDocumentNamespace

 /**
  * Resolves a registered namespace alias to the full namespace.
  *
  * @param string $documentNamespaceAlias 
  * @return string
  * @throws MongoDBException
  */
 public function getDocumentNamespace($documentNamespaceAlias)
 {
     if (!isset($this->attributes['documentNamespaces'][$documentNamespaceAlias])) {
         throw MongoDBException::unknownDocumentNamespace($documentNamespaceAlias);
     }
     return trim($this->attributes['documentNamespaces'][$documentNamespaceAlias], '\\');
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:14,代码来源:Configuration.php


示例4: getAliasNamespace

 /**
  * Resolves a registered namespace alias to the full namespace.
  *
  * @param string $alias
  * @return string
  * @throws MongoDBException
  */
 public function getAliasNamespace($alias)
 {
     foreach (array_keys($this->getManagers()) as $name) {
         try {
             return $this->getManager($name)->getConfiguration()->getDocumentNamespace($alias);
         } catch (MongoDBException $e) {
         }
     }
     throw MongoDBException::unknownDocumentNamespace($alias);
 }
开发者ID:Wizkunde,项目名称:DoctrineMongoDBBundle,代码行数:17,代码来源:ManagerRegistry.php


示例5: loadMetadataForClass

 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass($className, ClassMetadataInfo $class)
 {
     foreach ($this->drivers as $namespace => $driver) {
         if (strpos($className, $namespace) === 0) {
             $driver->loadMetadataForClass($className, $class);
             return;
         }
     }
     throw MongoDBException::classIsNotAValidDocument($className);
 }
开发者ID:romainneutron,项目名称:mongodb-odm,代码行数:13,代码来源:DriverChain.php


示例6: __load

 public function __load()
 {
     if (!$this->__isInitialized__ && $this->__documentPersister__) {
         $this->__isInitialized__ = true;
         if ($this->__documentPersister__->load($this->__identifier__, $this) === null) {
             throw \Doctrine\ODM\MongoDB\MongoDBException::documentNotFound(get_class($this), $this->__identifier__);
         }
         unset($this->__documentPersister__, $this->__identifier__);
     }
 }
开发者ID:rfanjul,项目名称:sfMongoFacebookTwitter,代码行数:10,代码来源:QuorraCoreBundleDocumentUserProxy.php


示例7: __clone

 public function __clone()
 {
     if (!$this->__isInitialized__ && $this->__documentPersister__) {
         $this->__isInitialized__ = true;
         $class = $this->__documentPersister__->getClassMetadata();
         $original = $this->__documentPersister__->load($this->__identifier__);
         if ($original === null) {
             throw \Doctrine\ODM\MongoDB\MongoDBException::documentNotFound(get_class($this), $this->__identifier__);
         }
         foreach ($class->reflFields as $field => $reflProperty) {
             $reflProperty->setValue($this, $reflProperty->getValue($original));
         }
         unset($this->__documentPersister__, $this->__identifier__);
     }
 }
开发者ID:superdweebie,项目名称:identity-module,代码行数:15,代码来源:__CG__SdsIdentityModuleDataModelForgotCredentialToken.php


示例8: doRemove

 /**
  * Deletes an document as part of the current unit of work.
  *
  * This method is internally called during delete() cascades as it tracks
  * the already visited documents to prevent infinite recursions.
  *
  * @param object $document The document to delete.
  * @param array $visited The map of the already visited documents.
  * @throws InvalidArgumentException If the instance is a detached document.
  */
 private function doRemove($document, array &$visited)
 {
     $oid = spl_object_hash($document);
     if (isset($visited[$oid])) {
         return;
         // Prevent infinite recursion
     }
     $visited[$oid] = $document;
     // mark visited
     $class = $this->dm->getClassMetadata(get_class($document));
     $documentState = $this->getDocumentState($document);
     switch ($documentState) {
         case self::STATE_NEW:
         case self::STATE_REMOVED:
             // nothing to do
             break;
         case self::STATE_MANAGED:
             if (isset($class->lifecycleCallbacks[Events::preRemove])) {
                 $class->invokeLifecycleCallbacks(Events::preRemove, $document);
             }
             if ($this->evm->hasListeners(Events::preRemove)) {
                 $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($document, $this->dm));
             }
             $this->scheduleForDelete($document);
             $this->cascadePreRemove($class, $document);
             break;
         case self::STATE_DETACHED:
             throw MongoDBException::detachedDocumentCannotBeRemoved();
         default:
             throw MongoDBException::invalidDocumentState($documentState);
     }
     $this->cascadeRemove($document, $visited);
 }
开发者ID:nextmotion,项目名称:mongodb-odm,代码行数:43,代码来源:UnitOfWork.php


示例9: __call

 /**
  * Adds support for magic finders.
  *
  * @param string $method
  * @param array $arguments
  * @throws MongoDBException
  * @throws \BadMethodCallException If the method called is an invalid find* method
  *                                 or no find* method at all and therefore an invalid
  *                                 method call.
  * @return array|object The found document/documents.
  */
 public function __call($method, $arguments)
 {
     if (strpos($method, 'findBy') === 0) {
         $by = substr($method, 6, strlen($method));
         $method = 'findBy';
     } elseif (strpos($method, 'findOneBy') === 0) {
         $by = substr($method, 9, strlen($method));
         $method = 'findOneBy';
     } else {
         throw new \BadMethodCallException("Undefined method: '{$method}'. The method name must start with 'findBy' or 'findOneBy'!");
     }
     if (!isset($arguments[0])) {
         throw MongoDBException::findByRequiresParameter($method . $by);
     }
     $fieldName = Inflector::camelize($by);
     if ($this->class->hasField($fieldName)) {
         return $this->{$method}(array($fieldName => $arguments[0]));
     } else {
         throw MongoDBException::invalidFindByCall($this->documentName, $fieldName, $method . $by);
     }
 }
开发者ID:doctrine,项目名称:mongodb-odm,代码行数:32,代码来源:DocumentRepository.php


示例10: enableShardingForDbByDocumentName

 /**
  * Enable sharding for database which contains documents with given name.
  *
  * @param string $documentName
  *
  * @throws MongoDBException
  */
 public function enableShardingForDbByDocumentName($documentName)
 {
     $dbName = $this->dm->getDocumentDatabase($documentName)->getName();
     $adminDb = $this->dm->getConnection()->selectDatabase('admin');
     $result = $adminDb->command(array('enableSharding' => $dbName));
     // Error code is only available with MongoDB 3.2. MongoDB 3.0 only returns a message
     // Thus, check code if it exists and fall back on error message
     if ($result['ok'] == 1 || isset($result['code']) && $result['code'] == 23 || $result['errmsg'] == 'already enabled') {
         return;
     }
     throw MongoDBException::failedToEnableSharding($dbName, $result['errmsg']);
 }
开发者ID:alcaeus,项目名称:mongodb-odm,代码行数:19,代码来源:SchemaManager.php


示例11: enableShardingForDbByDocumentName

 /**
  * Enable sharding for database which contains documents with given name.
  *
  * @param string $documentName
  *
  * @throws MongoDBException
  */
 public function enableShardingForDbByDocumentName($documentName)
 {
     $dbName = $this->dm->getDocumentDatabase($documentName)->getName();
     $adminDb = $this->dm->getConnection()->selectDatabase('admin');
     $result = $adminDb->command(array('enableSharding' => $dbName));
     if ($result['ok'] != 1 && $result['errmsg'] !== 'already enabled') {
         throw MongoDBException::failedToEnableSharding($dbName, $result['errmsg']);
     }
 }
开发者ID:briareos,项目名称:mongodb-odm,代码行数:16,代码来源:SchemaManager.php


示例12: findMappingFile

 protected function findMappingFile($className)
 {
     $defaultFileName = str_replace('\\', '.', $className) . $this->fileExtension;
     foreach ($this->paths as $path) {
         if (!isset($this->prefixes[$path])) {
             if (file_exists($path . DIRECTORY_SEPARATOR . $defaultFileName)) {
                 return $path . DIRECTORY_SEPARATOR . $defaultFileName;
             }
             continue;
         }
         $prefix = $this->prefixes[$path];
         if (0 !== strpos($className, $prefix . '\\')) {
             continue;
         }
         $filename = $path . '/' . strtr(substr($className, strlen($prefix) + 1), '\\', '.') . $this->fileExtension;
         if (file_exists($filename)) {
             return $filename;
         }
         throw MongoDBException::mappingNotFound($className, $filename);
     }
     throw MongoDBException::mappingNotFound($className, substr($className, strrpos($className, '\\') + 1) . $this->fileExtension);
 }
开发者ID:hafeez3000,项目名称:DoctrineMongoDBBundle,代码行数:22,代码来源:YamlDriver.php


示例13: doRemove

 /**
  * Deletes a document as part of the current unit of work.
  *
  * This method is internally called during delete() cascades as it tracks
  * the already visited documents to prevent infinite recursions.
  *
  * @param object $document The document to delete.
  * @param array $visited The map of the already visited documents.
  * @throws MongoDBException
  */
 private function doRemove($document, array &$visited)
 {
     $oid = spl_object_hash($document);
     if (isset($visited[$oid])) {
         return;
         // Prevent infinite recursion
     }
     $visited[$oid] = $document;
     // mark visited
     /* Cascade first, because scheduleForDelete() removes the entity from
      * the identity map, which can cause problems when a lazy Proxy has to
      * be initialized for the cascade operation.
      */
     $this->cascadeRemove($document, $visited);
     $class = $this->dm->getClassMetadata(get_class($document));
     $documentState = $this->getDocumentState($document);
     switch ($documentState) {
         case self::STATE_NEW:
         case self::STATE_REMOVED:
             // nothing to do
             break;
         case self::STATE_MANAGED:
             if (!empty($class->lifecycleCallbacks[Events::preRemove])) {
                 $class->invokeLifecycleCallbacks(Events::preRemove, $document);
             }
             if ($this->evm->hasListeners(Events::preRemove)) {
                 $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($document, $this->dm));
             }
             $this->scheduleForDelete($document);
             break;
         case self::STATE_DETACHED:
             throw MongoDBException::detachedDocumentCannotBeRemoved();
         default:
             throw MongoDBException::invalidDocumentState($documentState);
     }
 }
开发者ID:kevinyien,项目名称:mongodb-odm,代码行数:46,代码来源:UnitOfWork.php


示例14: loadMetadata

 /**
  * Loads the metadata of the class in question and all it's ancestors whose metadata
  * is still not loaded.
  *
  * @param string $name The name of the class for which the metadata should get loaded.
  * @param array  $tables The metadata collection to which the loaded metadata is added.
  */
 private function loadMetadata($className)
 {
     if (!$this->initialized) {
         $this->initialize();
     }
     $loaded = array();
     $parentClasses = $this->getParentClasses($className);
     $parentClasses[] = $className;
     // Move down the hierarchy of parent classes, starting from the topmost class
     $parent = null;
     $visited = array();
     foreach ($parentClasses as $className) {
         if (isset($this->loadedMetadata[$className])) {
             $parent = $this->loadedMetadata[$className];
             if (!$parent->isMappedSuperclass && !$parent->isEmbeddedDocument) {
                 array_unshift($visited, $className);
             }
             continue;
         }
         $class = $this->newClassMetadataInstance($className);
         if ($parent) {
             if (!$parent->isMappedSuperclass) {
                 $class->setInheritanceType($parent->inheritanceType);
                 $class->setDiscriminatorField($parent->discriminatorField);
                 $class->setDiscriminatorMap($parent->discriminatorMap);
             }
             $class->setIdGeneratorType($parent->generatorType);
             $this->addInheritedFields($class, $parent);
             $this->addInheritedIndexes($class, $parent);
             $class->setIdentifier($parent->identifier);
             $class->setVersioned($parent->isVersioned);
             $class->setVersionField($parent->versionField);
             $class->setLifecycleCallbacks($parent->lifecycleCallbacks);
             $class->setChangeTrackingPolicy($parent->changeTrackingPolicy);
             $class->setFile($parent->getFile());
         }
         // Invoke driver
         try {
             $this->driver->loadMetadataForClass($className, $class);
         } catch (ReflectionException $e) {
             throw MongoDBException::reflectionFailure($className, $e);
         }
         if (!$class->identifier && !$class->isMappedSuperclass && !$class->isEmbeddedDocument) {
             throw MongoDBException::identifierRequired($className);
         }
         if ($parent && !$parent->isMappedSuperclass && !$class->isEmbeddedDocument) {
             if ($parent->generatorType) {
                 $class->setIdGeneratorType($parent->generatorType);
             }
             if ($parent->generatorOptions) {
                 $class->setIdGeneratorOptions($parent->generatorOptions);
             }
             if ($parent->idGenerator) {
                 $class->setIdGenerator($parent->idGenerator);
             }
         } else {
             $this->completeIdGeneratorMapping($class);
         }
         if ($parent && $parent->isInheritanceTypeSingleCollection()) {
             $class->setDatabase($parent->getDatabase());
             $class->setCollection($parent->getCollection());
         }
         $db = $class->getDatabase() ?: $this->config->getDefaultDB();
         $class->setDatabase($this->dm->formatDBName($db));
         $class->setParentClasses($visited);
         if ($this->evm->hasListeners(Events::loadClassMetadata)) {
             $eventArgs = new \Doctrine\ODM\MongoDB\Event\LoadClassMetadataEventArgs($class, $this->dm);
             $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs);
         }
         $this->loadedMetadata[$className] = $class;
         $parent = $class;
         if (!$class->isMappedSuperclass && !$class->isEmbeddedDocument) {
             array_unshift($visited, $className);
         }
         $loaded[] = $className;
     }
     return $loaded;
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:85,代码来源:ClassMetadataFactory.php


示例15: execute

 /**
  * Execute the query and returns the results.
  *
  * @return mixed
  */
 public function execute()
 {
     $uow = $this->dm->getUnitOfWork();
     if ($this->isIndexRequired() && !$this->isIndexed()) {
         throw MongoDBException::queryNotIndexed($this->class->name, $this->getUnindexedFields());
     }
     $results = parent::execute();
     $hints = array();
     if ($this->refresh) {
         $hints[self::HINT_REFRESH] = true;
     }
     if ($this->query['slaveOkay'] === true) {
         $hints[self::HINT_SLAVE_OKAY] = true;
     }
     // Unwrap the BaseEagerCursor
     if ($results instanceof BaseEagerCursor) {
         $results = $results->getCursor();
     }
     // Convert the regular mongodb cursor to the odm cursor
     if ($results instanceof BaseCursor) {
         $results = $this->wrapCursor($results, $hints);
     }
     // Wrap odm cursor with EagerCursor if true
     if ($this->query['eagerCursor'] === true) {
         $results = new EagerCursor($results, $this->dm->getUnitOfWork(), $this->class);
     }
     // GeoLocationFindQuery just returns an instance of ArrayIterator so we have to
     // iterator over it and hydrate each object.
     if ($this->query['type'] === self::TYPE_GEO_LOCATION && $this->hydrate) {
         foreach ($results as $key => $result) {
             $document = $result['obj'];
             if ($this->class->distance) {
                 $document[$this->class->distance] = $result['dis'];
             }
             $results[$key] = $uow->getOrCreateDocument($this->class->name, $document, $hints);
         }
         $results->reset();
     }
     if ($this->primers) {
         $documentPersister = $this->dm->getUnitOfWork()->getDocumentPersister($this->class->name);
         foreach ($this->primers as $fieldName => $primer) {
             if ($primer) {
                 $documentPersister->primeCollection($results, $fieldName, $primer, $hints);
             }
         }
     }
     if ($this->hydrate && is_array($results) && isset($results['_id'])) {
         // Convert a single document array to a document object
         $results = $uow->getOrCreateDocument($this->class->name, $results, $hints);
     }
     return $results;
 }
开发者ID:noikiy,项目名称:inovi,代码行数:57,代码来源:Query.php


示例16: getShardKeyQuery

 /**
  * @param $document
  * @return array
  * @throws MongoDBException
  */
 public function getShardKeyQuery($document)
 {
     $shardKeysQueryPart = array();
     $dcs = $this->uow->getDocumentChangeSet($document);
     $data = $this->uow->getDocumentActualData($document);
     $md = $this->dm->getMetadataFactory()->getMetadataFor(get_class($document));
     $keys = $md->shardKeys;
     $fieldMappings = $this->dm->getClassMetadata(get_class($document))->fieldMappings;
     foreach ($keys as $key) {
         if ($key !== 'id') {
             $queryKey = $fieldMappings[$key]['name'];
         } else {
             $queryKey = '_id';
         }
         //If the document is new, we can ignore shard key value, otherwise throw exception
         $isUpdate = $this->uow->isScheduledForUpdate($document);
         if ($isUpdate && isset($dcs[$key]) && $dcs[$key][0] !== null && $dcs[$key][0] != $dcs[$key][1] && (!isset($options['upsert']) || isset($options['upsert']) && $options['upsert'] === true)) {
             throw MongoDBException::shardKeyChange($key);
         }
         if (!isset($data[$key])) {
             throw MongoDBException::shardKeyMissing($key);
         }
         $new = $data[$key];
         $mapping = $fieldMappings[$key];
         // @Field, @String, @Date, etc.
         if (!isset($mapping['association'])) {
             if (isset($new) || $mapping['nullable'] === true) {
                 $shardKeysQueryPart[$queryKey] = is_null($new) ? null : Type::getType($mapping['type'])->convertToDatabaseValue($new);
             }
             // @ReferenceOne
         } elseif (isset($mapping['association']) && $mapping['association'] === ClassMetadata::REFERENCE_ONE && $mapping['isOwningSide']) {
             if (isset($new) || $mapping['nullable'] === true) {
                 $shardKeysQueryPart[$queryKey] = is_null($new) ? null : $this->pb->prepareReferencedDocumentValue($mapping, $new);
             }
             // @ReferenceMany
         } elseif (isset($mapping['association']) && $mapping['association'] === ClassMetadata::REFERENCE_MANY) {
             // Do nothing right now
         }
     }
     return $shardKeysQueryPart;
 }
开发者ID:backplane,项目名称:mongodb-odm,代码行数:46,代码来源:DocumentPersister.php


示例17: execute

 /**
  * Execute the query and returns the results.
  *
  * @throws \Doctrine\ODM\MongoDB\MongoDBException
  * @return mixed
  */
 public function execute()
 {
     if ($this->isIndexRequired() && !$this->isIndexed()) {
         throw MongoDBException::queryNotIndexed($this->class->name, $this->getUnindexedFields());
     }
     $results = parent::execute();
     if (!$this->hydrate) {
         return $results;
     }
     $uow = $this->dm->getUnitOfWork();
     /* A geoNear command returns an ArrayIterator, where each result is an
      * object with "dis" (computed distance) and "obj" (original document)
      * properties. If hydration is enabled, eagerly hydrate these results.
      *
      * Other commands results are not handled, since their results may not
      * resemble documents in the collection.
      */
     if ($this->query['type'] === self::TYPE_GEO_NEAR) {
         foreach ($results as $key => $result) {
             $document = $result['obj'];
             if ($this->class->distance !== null) {
                 $document[$this->class->distance] = $result['dis'];
             }
             $results[$key] = $uow->getOrCreateDocument($this->class->name, $document, $this->unitOfWorkHints);
         }
         $results->reset();
     }
     /* If a single document is returned from a findAndModify command and it
      * includes the identifier field, attempt hydration.
      */
     if (($this->query['type'] === self::TYPE_FIND_AND_UPDATE || $this->query['type'] === self::TYPE_FIND_AND_REMOVE) && is_array($results) && isset($results['_id'])) {
         $results = $uow->getOrCreateDocument($this->class->name, $results, $this->unitOfWorkHints);
     }
     if (!empty($this->primers)) {
         $referencePrimer = new ReferencePrimer($this->dm, $uow);
         foreach ($this->primers as $fieldName => $primer) {
             $primer = is_callable($primer) ? $primer : null;
             $documents = $results instanceof Iterator ? $results : array($results);
             $referencePrimer->primeReferences($this->class, $documents, $fieldName, $this->unitOfWorkHints, $primer);
         }
     }
     return $results;
 }
开发者ID:briareos,项目名称:mongodb-odm,代码行数:49,代码来源:Query.php


示例18: prepareUpdateData

 /**
  * Prepares update array for document, using atomic operators
  *
  * @param mixed $document
  * @return array
  */
 public function prepareUpdateData($document)
 {
     $oid = spl_object_hash($document);
     $changeset = $this->_uow->getDocumentChangeSet($document);
     $result = array();
     foreach ($this->_class->fieldMappings as $mapping) {
         if (isset($mapping['notSaved']) && $mapping['notSaved'] === true) {
             continue;
         }
         $old = isset($changeset[$mapping['fieldName']][0]) ? $changeset[$mapping['fieldName']][0] : null;
         $new = isset($changeset[$mapping['fieldName']][1]) ? $changeset[$mapping['fieldName']][1] : null;
         $new = $this->_prepareValue($mapping, $new);
         $old = $this->_prepareValue($mapping, $old);
         if ($this->_class->isIdentifier($mapping['fieldName']) && !$this->_equals($new, $old)) {
             throw MongoDBException::identifierCannotBeUpdated();
         }
         if ($mapping['type'] === 'many' || $mapping['type'] === 'collection') {
             $this->_addArrayUpdateAtomicOperator($mapping, (array) $new, (array) $old, $result);
         } else {
             $this->_addFieldUpdateAtomicOperator($mapping, $new, $old, $result);
         }
     }
     return $result;
 }
开发者ID:klaasn,项目名称:symfony-sandbox,代码行数:30,代码来源:BasicDocumentPersister.php


示例19: getFieldMapping

 /**
  * Gets the mapping of a field.
  *
  * @param string $fieldName  The field name.
  * @return array  The field mapping.
  */
 public function getFieldMapping($fieldName)
 {
     if (!isset($this->fieldMappings[$fieldName])) {
         throw MongoDBException::mappingNotFound($this->name, $fieldName);
     }
     return $this->fieldMappings[$fieldName];
 }
开发者ID:skoop,项目名称:symfony-sandbox,代码行数:13,代码来源:ClassMetadata.php


示例20: __call

 /**
  * Adds support for magic finders.
  *
  * @param string $method
  * @param array $arguments
  * @throws MongoDBException
  * @throws \BadMethodCallException If the method called is an invalid find* method
  *                                 or no find* method at all and therefore an invalid
  *                                 method call.
  * @return array|object The found document/documents.
  */
 public function __call($method, $arguments)
 {
     if (substr($method, 0, 6) == 'findBy') {
         $by = substr($method, 6, strlen($method));
         $method = 'findBy';
     } elseif (substr($method, 0, 9) == 'findOneBy') {
         $by = substr($method, 9, strlen($method));
         $method = 'findOneBy';
     } else {
         throw new \BadMethodCallException("Undefined method '{$method}'. The method name must start with " . "either findBy or findOneBy!");
     }
     if (!isset($arguments[0])) {
         throw MongoDBException::findByRequiresParameter($method . $by);
     }
     $fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($by));
     if ($this->class->hasField($fieldName)) {
         return $this->{$method}(array($fieldName => $arguments[0]));
     } else {
         throw MongoDBException::invalidFindByCall($this->documentName, $fieldName, $method . $by);
     }
 }
开发者ID:briareos,项目名称:mongodb-odm,代码行数:32,代码来源:DocumentRepository.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP MongoDB\UnitOfWork类代码示例发布时间:2022-05-23
下一篇:
PHP Types\Type类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap