views:

94

answers:

2

Hi Everyone!

Ok so I got this piece of vendor software that they said should be run on an apache php server and MySql database.

I didn't have either of those so I put it on a PHP IIS server and I converted the code to work on SQL server.

ex.
mysql_select_db -> mssql_select_db
(among other things)

So I have the following code in a php file

$query = "SELECT * FROM TableName WHERE KEY_FIELD = '".$keyField."';";

$result = mssql_query($query); 

$arr = array();
while ( $obj = mssql_fetch_object($result) ) 
{
    $arr[] = $obj;  
}

echo '{"results":'.json_encode($arr).'}';

and my results look something like this (captured with fiddler 2)

{"results":[{"KEY_FIELD":"57", "My30characterlongfieldthatiscu":"GoodValue"}]}

"My30characterlongfieldthatiscu" should be "My30characterlongfieldthatiscutoff"

Kinda weird, no?

The vendor claims that the app works perfectly on their end.

I'm thinking this is some sort of IIS PHP limit, is there a way around it or can I expand it?

I found this solution http://www.php.net/manual/en/ref.mssql.php#74834 but I don't understand it.

Thanks!

+1  A: 

http://docs.php.net/manual/en/mssql.requirements says:

Note: On 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.

Is using the sqlsrv extension instead of mssql an option?

VolkerK
Hmm, lets try to find out how to install this...
Biff MaGriff
A: 

See http://bugs.php.net/bug.php?id=33060 - this is what's causing your issue.

You might also want to consider changing the column names - more than 30 characters sounds excessively long.

ThiefMaster
Yeah 30 characters is rediculous. I'm kinda hesitant to do so just because when the vendor does updates I'll have more work to do :(
Biff MaGriff