0

我关注 了如何将 ZF2 与 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/
4

1 回答 1

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

应该解决这些问题

于 2012-05-03T14:26:49.843 回答