开发者

SQL Server returned column name truncated to 29 characters using PHP

开发者 https://www.devze.com 2023-02-03 10:10 出处:网络
I have a SQL Server query that I take the result from and insert into an array like while($row = mssql_fetch_array($res,

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 ab开发者_开发百科out 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.


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


this: What is the max key size for an array in PHP? seems te imply that you're not having trouble with a PHP array-key limit


  1. Make sure the column in your database is definetly called customer_social_sequrity_number and is not cut off
  2. Check this is definetly the key and not the value of the array, if it's the value then it's data rather than column name
0

精彩评论

暂无评论...
验证码 换一张
取 消