douzhoulei8959 2011-01-11 14:12
浏览 40
已采纳

SQL Server使用PHP将列名截断为29个字符

I have a SQL Server query that I take the result from and insert into an array like

while($row = mssql_fetch_array($res, MSSQL_ASSOC)) { ... }

Now, the problem is that looking at the $row I see that the column named customer_social_sequrity_number becomes the key customer_social_sequrity_numbe. All other keys seems to be trunkated to 29 characters to. Is this a limit? I can't find any information about such a limit.

This is a bit of a drag since I'm importing data from a 3rd party database and use the key of the array to mapp the data to an object.

Does not seem to be a limitation on the PHP side as stated. Is it possibly some limitation on the SQL Server part? Running the query using MS Query Analyzer it seems fine.

  • 写回答

3条回答 默认 最新

  • dpe77294 2011-01-11 14:55
    关注

    I found the answer to the question. It seems like in Windows, Microsoft's DBLIB is used and functions that return a column name are based on the dbcolname() function in DBLIB. DBLIB was apperently developed for SQL Server 6 where the max length of a columnname was 30. For this reason, the maximum column length is 30 characters.

    Here you can get a version of FreeTDS for Windows that hopefully eliviates this problem: http://docs.moodle.org/en/Installing_MSSQL_for_PHP#Using_FreeTDS_on_Windows

    Also on Linux this will not be a problem it only affects Windows

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应