1

我有一个User带有字段的实体userName(带有适当的 getter 和 setter),它映射到user_nametable中的字段users。在UserRepository我从数据库中获取一条记录并且我有$userUser。如何找出表和字段名称$user->userName?我需要以某种方式从注释中获取信息。我发现此信息在 Doctrine2 缓存中,并且我找到了 ClassMetadataInfo 类文档,但我不知道如何将它们放在一起。

4

1 回答 1

5

You should be able to get the class metadata of a specific class by doing so:

$entityManager->getClassMetadata(get_class($user))
于 2012-07-07T17:13:48.153 回答