douyinzha5820
2011-10-25 08:27
浏览 28
已采纳

PHP Doctrine使用鉴别器映射查询继承的类

In this example:

http://www.doctrine-project.org/docs/orm/2.0/en/reference/dql-doctrine-query-language.html#single-table

we see that

SELECT e FROM Entities\Employee e WHERE e.name = 'test'

makes this query:

 SELECT p0_.id AS id0, p0_.name AS name1, p0_.department AS department2,
        p0_.discr AS discr3 FROM Person p0_ WHERE (p0_.name = ?) AND p0_.discr IN ('employee')

Is there a way to query records only with the discriminator "Person"?

This:

SELECT e FROM Entities\Person e WHERE e.name = 'test'

returns all the records.

Any ideas?

图片转代码服务由CSDN问答提供 功能建议

在此示例中:

http://www.doctrine-project.org/ docs / orm / 2.0 / en / reference / dql-doctrine-query-language.html#single-table

我们看到了 < pre> SELECT e FROM Entities \ Employee e WHERE e.name ='test'

进行此查询: < pre> SELECT p0_.id AS id0,p0_.name AS name1,p0_.department AS department2, p0_discr AS discrimin3 FROM Person p0_ WHERE(p0_.name =?)AND p0_.discr IN('employee ')

有没有办法只使用鉴别器“Person”查询记录?

这个:

  SELECT e FROM Entities \ Person e WHERE e.name ='test'
   
 
 

返回所有记录。

有什么想法吗?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题