Php CouchDb Symfony2中的映射实体
我在symfony2.7.2中使用couchDb 我有几个疑问。 现在我安装了这个 我创建了一个用于测试的实体Php CouchDb Symfony2中的映射实体,php,symfony,doctrine-orm,couchdb,Php,Symfony,Doctrine Orm,Couchdb,我在symfony2.7.2中使用couchDb 我有几个疑问。 现在我安装了这个 我创建了一个用于测试的实体 <?php namespace foo\GarageBundle\Document; use Doctrine\ODM\CouchDB\Mapping\Annotations as CouchDB; /** * @CouchDB\Document */ class Utente { /** @CouchDB\Id */ private $id;
<?php
namespace foo\GarageBundle\Document;
use Doctrine\ODM\CouchDB\Mapping\Annotations as CouchDB;
/**
* @CouchDB\Document
*/
class Utente
{
/** @CouchDB\Id */
private $id;
/** @CouchDB\Field(type="string") */
private $nome;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set nome
*
* @param string $nome
* @return Utente
*/
public function setNome($nome)
{
$this->nome = $nome;
return $this;
}
/**
* Get nome
*
* @return string
*/
public function getNome()
{
return $this->nome;
}
}
我的config.yml是
doctrine_couch_db:
client:
default_connection: default
connections:
default:
dbname: symfony2
odm:
default_document_manager: default
document_managers:
default:
auto_mapping: true
使用controller,我创建了数据库,但无法插入新文档,我遇到了此错误
The class 'foo\GarageBundle\Document\Utente' was not found in the chain configured namespaces
我不明白为什么像我现在使用的一样使用bundle是有用的(我知道这可能是一个愚蠢的问题),为什么我必须在实体内部使用
*@CouchDB\Document
而不是@Document
?似乎是与实体类的名称空间相关的问题
自动映射正在注册
您的捆绑包,而不是文档(由
DoctrineMongoDBBundle)
因此,请为User
类和您使用的其他类使用不同的名称空间,如下所示:
namespace foo\GarageBundle\CouchDocument;
特别是:
<?php
namespace foo\GarageBundle\CouchDocument;
use Doctrine\ODM\CouchDB\Mapping\Annotations as CouchDB;
/**
* @CouchDB\Document
*/
class Utente
{
Hi@monkeyUser欢迎您!我不认为这是一个很琐碎的问题:这个需求并没有很好的文档化。现在它可以工作了,但我无法从我的数据库中检索文档<代码>$dm=$this->container->get('doctrine\u couchdb.odm.default\u document\u manager')$users=$dm->getRepository('myGarageBundle:utete')->findAll()代码>我有三个文档,但我的数组是空的。
<?php
namespace foo\GarageBundle\CouchDocument;
use Doctrine\ODM\CouchDB\Mapping\Annotations as CouchDB;
/**
* @CouchDB\Document
*/
class Utente
{
/**
* @CouchDB\Document
* @CouchDB\Index
*/
class Utente
{