奇怪的别名[0_在试图用SQL SERVER运行时被添加 [英] Weird alias [0_ added by doctrine while trying to run with SQL SERVER

查看:186
本文介绍了奇怪的别名[0_在试图用SQL SERVER运行时被添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQL Server在Symfony上实现APYDataGridBundle。 Symfony引发了这个例外:

I'm trying to implement APYDataGridBundle on Symfony, with SQL Server. Symfony throws in this exception:


SQLSTATE [HY000]:常规错误:105常规SQL Server错误:检查SQL Server [105 ](严重性15)[SELECT TOP 50 [0_.PI_PK AS PI_PK0,[0_.ProductName AS ProductName1,[0_.ProductDetails AS ProductDetails2 FROM [TSOFT_LEARN]。[dbo]。[tblProductDemo] [0_]

SQLSTATE[HY000]: General error: 105 General SQL Server error: Check messages from the SQL Server [105] (severity 15) [SELECT TOP 50 [0_.PI_PK AS PI_PK0, [0_.ProductName AS ProductName1, [0_.ProductDetails AS ProductDetails2 FROM [TSOFT_LEARN].[dbo].[tblProductDemo] [0_]

我试过:

$repo = $em->getRepository("ProductOrderLookupBundle:Product");
$product = $repo->findAll();

一切都正常,但是它超过100万条记录。有人建议我使用APYDatagridBundle,如 here 。我以前尝试过ThraceDataGrid Bundle,它给了我同样的问题。
如果我在SQL Server上运行查询时删除了[0_和一切正常工作。

and everything worked fine, but it breaks for over 1 million records. Someone suggested to me to use APYDatagridBundle like here. I have tried ThraceDataGrid Bundle before and it gave me this same problem. If I remove the "[0_" and everything worked fine while running the query on SQL Server.

有人可以告诉我可能是什么问题? / p>

Can anybody tell me what might be the problem?

推荐答案

**解决方案:**问题是我如何在教义实体中定义我的表名。我给了名字

**SOLVED:**The problem was with how I defined my table names in the doctrine entities. I gave the name

[TSOFT_LEARN].[dbo].[tblOrders]

它应该是

TSOFT_LEARN.dbo.tblOrders

因为我的别名正在变成[0_而不是t0_]我认为它是如何通过使用表名的第一个字符来创建它的别名。由于表名以[]开头,所以别名已转换为[0 _。

Because of that my alias was becoming [0_ instead of t0_. I suppose its how doctrine creates its aliases by taking the first character of the table name. Since the table name was starting with "[" the alias got converted to [0_.

这篇关于奇怪的别名[0_在试图用SQL SERVER运行时被添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆