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


PHP MongoDBException::invalidFindByCall方法代码示例

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


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

示例1: __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

示例2: __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


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