简体   繁体   English

原则2-IBM DB2

[英]Doctrine 2 - IBM DB2

I have problem while mapping DB2 Table with Doctrine 2. Application exists for a long time and for strange reason there was a "£" special char added in front of some columns names. 在使用Doctrine 2映射DB2表时遇到问题。应用程序存在很长时间,并且由于奇怪的原因,在某些列名称的前面添加了“£”特殊字符。

Ex : £ADRB1 例如:£ADRB1

While checking documentation, it appreared that this is something Doctrine does not like very much. 在检查文档时,它认为这是Doctrine非常不喜欢的东西。 By the way, connection is made through a ODBC driver :/ which I cannot change. 顺便说一下,连接是通过ODBC驱动程序:/进行的,我无法更改。

Entity column is configured this way : 实体列的配置方式如下:

/**
 * @ORM\Column(name = "`£ADRB1`", type="string", length=38, options={"default":""})
 */
protected $ADRB1;

Error is 错误是

SQLSTATE[HY090]: Invalid string or buffer length: 0 [IBM][System i Access ODBC Driver]Invalid string or buffer length. SQLSTATE [HY090]:无效的字符串或缓冲区长度:0 [IBM] [System i Access ODBC驱动程序]无效的字符串或缓冲区长度。 (SQLPrepare[0] at /patched-php-src-5.5.7/php-5.5.7/ext/pdo_odbc/odbc_driver.c:206) (位于/patched-php-src-5.5.7/php-5.5.7/ext/pdo_odbc/odbc_driver.c:206的SQLPrepare [0])

While trying to fetch result with simple queryBuilder. 尝试使用简单的queryBuilder获取结果时。

Is there any possibility to be able to get it work with Doctrine 2 ? 是否有可能使它与Doctrine 2一起使用?

Many thanks ! 非常感谢 !

I know nothing about Doctrine2, but if the origin for the issue has anything to do with the column name [ which seems at least somewhat tenuous given the error implies nothing about a column name ], then probably the issue is related to the name of the column [at what is presumably an IBM i as the server] having the first character defined using the EBCDIC code-point 0x5B. 我对Doctrine2一无所知,但是如果问题的根源与列名有关[ 由于错误提示列名与列名无关, 这似乎至少有些微不足道 ],那么问题可能与列名有关列(大概是IBM i作为服务器)具有使用EBCDIC代码点0x5B定义的第一个字符。

While that EBCDIC code-point x'5B' is valid to represent the variant Dollar Sign character in some code pages [a valid but discouraged character, just like the @; 尽管该EBCDIC代码点x'5B'有效表示某些代码页中的变体 美元符号字符[一个有效但不鼓励使用的字符,就像@; see: Using @ on Variable Names ], the Pound Sterling Sign character [ASCII code-point 0xA3] sent from an ASCII client may not get translated to the EBCDIC code-point x'5B'. 请参阅: 在变量名上使用@ ],从ASCII客户端发送的英镑符号 [ASCII码点0xA3]可能不会转换为EBCDIC码点x'5B'。 The outcome depends on how the server is configured for the Code Page, and quite likely the character would translate to the EBCDIC code-point 0xB1; 结果取决于代码页服务器的配置方式,很有可能字符会转换为EBCDIC代码点0xB1; a code-point that is unlikely to represent a valid character for an SQL identifier such as a column name. 一个代码点,不太可能代表SQL标识符(例如列名)的有效字符。

So if the client can refer to the column name having specified the first character as the $ character instead of as the £ character, then when the expected\\proper character conversion from ASCII to EBCDIC occurs, the server will correctly see the column name as the expected name; 因此,如果客户端可以将已指定第一个字符的列名指定为$字符而不是£字符,那么当发生预期的\\正确字符从ASCII转换为EBCDIC时,服务器将正确地将列名视为预期名称; ie will in effect , see the characters $ADRB1 in EBCDIC [hex:5BC1C4D9C2F1] as translated from the ASCII characters $ADRB1 [hex:2441445231] rather than the likely\\undesirable outcome instead whereby the server in effect will see the characters £ADRB1 in EBCDIC [hex:B1C1C4D9C2F1] as translated from the ASCII characters £ADRB1 [hex:A341445231]. 实际上会看到EBCDIC [hex:5BC1C4D9C2F1]中的字符$ ADRB1是从ASCII字符$ ADRB1 [hex:2441445231]转换而来的,而不是可能的\\不良结果,实际上服务器会其中看到字符£ADRB1 EBCDIC [hex:B1C1C4D9C2F1],从ASCII字符£ADRB1 [hex:A341445231]翻译而来。

ps The tag DB2i is defined in the wiki as the DB2 for IBM i and the tag DB2 is defined in the wiki as the DB2 family , but the tag ibm-db2 has no definition https://stackoverflow.com/tags/ibm-db2/info , so if the server is IBM i with the DB2 for i as the database, then perhaps the DB2i is a better [or additional] choice for tagging this topic.? ps标记DB2i在Wiki中定义为IBM iDB2,而标记DB2在Wiki中定义为DB2家族 ,但是标记ibm-db2没有定义https://stackoverflow.com/tags/ibm- db2 / info ,因此,如果服务器是IBM i,并且DB2 for i作为数据库,那么DB2i也许是标记此主题的更好(或其他)选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM