Doctrine-PostgreSQL-表/字段名称中的大写字母和空格 [英] Doctrine - PostgreSQL - Uppercase and Spaces in Table / Field names

查看:127
本文介绍了Doctrine-PostgreSQL-表/字段名称中的大写字母和空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Doctrine 2.3和PostgreSQL带有空格和大写字段/表名的问题

Having issues with Doctrine 2.3 and PostgreSQL with Spaces and Upper case Field / Table names

示例:(是的,我们正在努力从此迁移)

Example: ( Yes we are working on migrating away from this )

SELECT "Field Name"
FROM "Table Name"

我们还有两种格式的组合

We also have a mix of the two formats

SELECT "Field Name", another_field_name
FROM "Table Name", another_table_name

使用学说时,我遇到了PDOException.在查看错误时,我发现在具有大写字母和空格的字段/表(名称)周围没有双引号.

When using doctrine I'm getting a PDOException. When looking at the error I see that there are no double quotes around Fields / Tables ( names ) that have Upper case and Spaces.

是否有修复程序?解决方法?

Is there a fix? Workaround?

这是教义所产生的例子

SELECT t0.TheId AS theid1, t0.Name AS name2, t0.User AS user3
FROM The Table t0 
WHERE t0.TheId = 1234

这就是我需要的

SELECT t0."TheId" AS theid1, t0."Name" AS name2, t0."User" AS user3
FROM "The Table" t0 
WHERE t0."TheId" = 1234

推荐答案

您可能需要使用反引号使教义知道应使用引号:

You may need to use backticks to let Doctrine know that it should be quoted: Quoting reserved words. E.g:

<?php
/** @Column(name="`number`", type="integer") */
private $number;

这篇关于Doctrine-PostgreSQL-表/字段名称中的大写字母和空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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