3

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.

inquam
  • 12,664
  • 15
  • 61
  • 101

3 Answers3

6

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

inquam
  • 12,664
  • 15
  • 61
  • 101
1

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

Community
  • 1
  • 1
Nanne
  • 64,065
  • 16
  • 119
  • 163
-1
  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
fire
  • 21,383
  • 17
  • 79
  • 114
  • The query contains `C.ED1 AS customer_social_sequrity_number`, so quite sure. And yes it IS the key. – inquam Jan 11 '11 at 14:27