ZF2与Doctrine Mongo ODM

时间:2012-05-02 15:59:21

标签: mongodb doctrine-orm zend-framework2

我跟着 How to integrate ZF2 with Doctrine Mongo ODM? 使用Doctrine Mongo ODM设置ZF2,

我可以将文档保存到mongodb中,但是我无法使用下面的代码

找到该文档
$dm = $this->getLocator()->get('mongo_dm');
$result = $dm->find('Item', '4f9ea557eabc88e96f000000');
print_r($result);

这是错误日志

PHP Warning:  class_parents(): Class Item does not exist and could not be loaded in /var/www/vendor/DoctrineMongoODMModule/vendor/mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php on line 347
PHP Warning:  array_reverse() expects parameter 1 to be array, boolean given in /var/www/vendor/DoctrineMongoODMModule/vendor/mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php on line 347
PHP Warning:  Invalid argument supplied for foreach() in /var/www/vendor/DoctrineMongoODMModule/vendor/mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php on line 347

我已经尝试使用

生成文档
./vendor/DoctrineModule/bin/doctrine odm:generate:documents ./module/Application/src/Application/

1 个答案:

答案 0 :(得分:1)

$dm = $this->getLocator()->get('mongo_dm');
$result = $dm->find('Application\Document\Item', '4f9ea557eabc88e96f000000');

应解决这些问题