Page 1 of 1

PHP and MSSQL

Posted: Thu Jan 25, 2007 8:05 am
by thomas777neo
Good Day

When I use a pure PHP to MSSQL connection and perform a SQL query as follows:

Code: Select all

SELECT contact_detail.contact_detail_type_id AS 'contact_detail.contact_detail_type_id' FROM db.dbo.contact_detail
It returns the following:

Code: Select all

array(1) { ["contact_detail.contact_detail_"]=> string(1) "2" }
I understand that the field name are very lengthy and not up to certain standards. Yet I require to have the full column name returned. As it limits the column name returned at 30 characters.

I am using the following:
Microsoft SQL Server 2005
Microsoft SQL Server Management Studio 9.00.1399.00
Microsoft Analysis Services Client Tools 2005.090.1399.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158)
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 7.0.5730.11
Microsoft .NET Framework 2.0.50727.42
Operating System 5.1.2600
PHP Version 5.1.1
Apache Version Apache/2.2.0 (Win32) DAV/2 mod_ssl/2.2.0 OpenSSL/0.9.8a mod_autoindex_color PHP/5.1.1

Its probably a small setting somewhere, thanks

Posted: Thu Jan 25, 2007 8:33 am
by volka
With "pure PHP to MSSQL connection" you mean mssql_connect and mssql_query?
http://de.php.net/mssql wrote:Note: In Windows, the DBLIB from Microsoft is used. Functions that return a column name are based on the dbcolname() function in DBLIB. DBLIB was developed for SQL Server 6.x where the max identifier length is 30. For this reason, the maximum column length is 30 characters. On platforms where FreeTDS is used (Linux), this is not a problem.

Posted: Fri Jan 26, 2007 12:43 am
by thomas777neo
With "pure PHP to MSSQL connection" you mean mssql_connect and mssql_query
- Yes

Is there anyway around this?

And thanks for the reply

Posted: Fri Jan 26, 2007 12:50 am
by volka
thomas777neo wrote:Is there anyway around this?
Not as long as php/win32 uses this opld library.

Posted: Fri Jan 26, 2007 12:51 am
by AKA Panama Jack
You are out of luck...

http://de3.php.net/manual/en/ref.mssql.php
Note: In Windows, the DBLIB from Microsoft is used. Functions that return a column name are based on the dbcolname() function in DBLIB. DBLIB was developed for SQL Server 6.x where the max identifier length is 30. For this reason, the maximum column length is 30 characters. On platforms where FreeTDS is used (Linux), this is not a problem.
If you want to get rid of the column name limit you need to upgrade the PHP server to Linux.

Posted: Fri Jan 26, 2007 1:20 am
by thomas777neo
That's not good :(

I guess the function is found in the ntwdblib.dll. Is it possible to reverse engineer and recreate the dll to allow a greater max identifier?

It seriously irritates me when stupid restrictions are placed.

Posted: Fri Jan 26, 2007 8:19 am
by volka
It's probably easier to make the extension use FreeTDS for win32 builds; don't know how difficult it would be.