PHP and MSSQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

PHP and MSSQL

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

thomas777neo wrote:Is there anyway around this?
Not as long as php/win32 uses this opld library.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post 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.
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

It's probably easier to make the extension use FreeTDS for win32 builds; don't know how difficult it would be.
Post Reply