PHP和SQL Server - 字段名称被截断

I have discovered that results coming from my SQL Server are having the field names truncated:

$query = "SELECT some_really_really_long_field_name FROM ..."
...
print_r($row);

array(
    'some_really_really_long_field_n' => 'value'
)

Does anyone know how to avoid this behaviour?

I think the database driver is ADODB.

So you don't have to count: the field names are being truncated to 31 characters.

SQL Server doesn't seem to mind the long field names in itself, so I can only presume that there is a char[32] string buffer somewhere in the ADODB driver which can't contain the long names.

You're probably using the decade-old, deprecated bundled MSSQL client. Use the new MSSQL driver for PHP from Microsoft or install the MSSQL client tools from your MSSQL server CD.

easiest way to avoid truncated field names is to use shorter field names....

Sorry, that sounds like a crappy answer, but it's much cleaner, easier to read and maintain, and just better practice.

you can use an alias for your long field names, something like this:

$query = "SELECT some_really_really_long_field_name AS short_alias FROM ..."

this will work for your current problem. But I suggest using PDO MSSQL driver to connect to database.