2012-05-02 151 views
0

我按照 How to integrate ZF2 with Doctrine Mongo ODM? 設置ZF2教義蒙戈ODM,ZF2與學說蒙戈ODM

我可以保存文檔到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/ 
+0

你有沒有設置自動加載你的 '項目' 類?否則它將無法工作。 – Ocramius

+1

嘗試使用命名空間類,例如$ result = $ dm-> find('Application \ Document \ Item','4f9ea557eabc88e96f000000'); – dextervip

+0

THanks Rafael,'Application \ Document \ Item'是正確的 –

回答

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

應該解決這些問題