In our web-app we use PHP5.2.6 + PDO to connect to a SQL Server 2005 database and store Russian texts.
Database collation is Cyrillic_General_CI_AS
, table collation is Cyrillic_General_CI_AS
, column type is NVARCHAR(MAX)
.
We tried connecting to a database using two following schemes, both causing different problems.
PDO mssql:
$dbh = new PDO ('mssql:host='.$mssql_server.';dbname='.$mssql_db, $mssql_login, $mssql_pwd);
in which case a result of a simple query like that:
SELECT field1 FROM tbl1 WHERE id=1
shows
field1
data truncated to 255 bytes.PDO odbc:
$dbh = new PDO ('odbc:DSN=myDSN;UID='.$mssql_login.';PWD='.$mssql_pwd);
in which case a result of the same query shows full not truncated data but with question marks instead of Russian symbols.
Notes:
- In the SQL Management Studio data is not truncated and Russian symbols are displayed properly as well.
- We have Windows 2003 Enterprise Edition SP2
So what should we choose as a connection method and how to fix corresponding issues?