我正在尝试使用doctrine / orm 2.5.1做一个简单的 – > find().
查询非常简单:
$this->get('order_repository')->find(10);
但这会产生一个复杂的查询:
SELECT s0_.number AS number_0,s0_.state AS state_1,s0_.completed_at AS completed_at_2,s0_.items_total AS items_total_3,s0_.adjustments_total AS adjustments_total_4,s0_.total AS total_5,s0_.created_at AS created_at_6,s0_.updated_at AS updated_at_7,s0_.deleted_at AS deleted_at_8,s0_.ID AS ID_9,s0_.expires_at AS expires_at_10,s1_.currency AS currency_11,s1_.checkout_state AS checkout_state_12,s1_.payment_state AS payment_state_13,s1_.shipPing_state AS shipPing_state_14,s2_.quantity AS quantity_15,s2_.unit_price AS unit_price_16,s2_.adjustments_total AS adjustments_total_17,s2_.total AS total_18,s2_.is_immutable AS is_immutable_19,s2_.ID AS ID_20,s1_.channel_ID AS channel_ID_21,s1_.shipPing_address_ID AS shipPing_address_ID_22,s1_.billing_address_ID AS billing_address_ID_23,s1_.customer_ID AS customer_ID_24,s1_.offer_ID AS offer_ID_25,s2_.order_ID AS order_ID_26,s2_.variant_ID AS variant_ID_27 FROM sylius_order s1_ left JOIN sylius_order_item s2_ ON s1_.ID = s2_.order_ID WHERE (s1_.ID = 10) AND (s1_.deleted_at IS NulL)’
出现以下错误:
sqlSTATE[42S22]: Column not found: 1054 UnkNown column ‘s0_.number’ in ‘fIEld List’
我可以看到s0_没有在查询的任何地方定义.这些别名是从教义自动的,我只是不明白它为什么使用s0_然后在FROM上跳过s1_,它有s0 _上提到的列.*最佳答案我刚刚花了一个小时来解决同样的问题;你可能犯了和我一样的拼写错误.
对我来说问题出在.yml模式定义中.在我定义表格之间关系的部分中,我有这个目标实体:
targetEntity:mlEmailNotif
代替
targetEntity:MlEmailNotif
因此小写的’m’使doctrine为新表创建一个新的别名(PHP比较区分大小写).
总结以上是内存溢出为你收集整理的php – 使用错误的表别名生成查询的Doctrine全部内容,希望文章能够帮你解决php – 使用错误的表别名生成查询的Doctrine所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)