教义生成错误的表别名的查询

教义生成错误的表别名的查询

本文介绍了教义生成错误的表别名的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用doctrine/orm 2.5.1做一个简单的->find().

I'm trying to do a simple ->find() using doctrine/orm 2.5.1.

查询非常简单:

$this->get('order_repository')->find(10);

但这会生成一个复杂的查询:

But this is generating a complex query:

出现以下错误:

我可以看到s0_在查询的任何地方都没有定义.这些别名是从理论上自动生成的,我只是不明白为什么要使用s0_,然后在FROM上将其跳过到s1_,而在s0_上提到了这些列.*

I can see that s0_ is not defined anywhere on the query. Those alias are automatic from doctrine, i just don't see why it's using s0_ and then skipping it to s1_ on the FROM which has the columns mentioned on s0_.*

推荐答案

我刚刚在这个问题上花了一个小时;您可能犯了与我相同的错字.

I've just spent an hour on this same problem; You probably made the same typo mistake as me.

对我来说,问题出在.yml模式定义中.在定义表之间关系的部分中,我有这个目标实体:

The problem for me was in the .yml schema definition. In the section where I defined the relations between my tables I had this target entity :

targetEntity: mlEmailNotif

代替

targetEntity: MlEmailNotif

因此,小写字母'm'使该学说为新表创建新别名(php比较区分大小写).

So the lowercase 'm' makes doctrine create a new alias for a new table (the php comparison is case sensitive).

这篇关于教义生成错误的表别名的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 04:31