Answer the question
In order to leave comments, you need to log in
How to overcome bugs when connecting to MsSql?
Gave access to an external database on mssql. Well, I don't know him. I do not understand how to explicitly specify the encoding there.
Russian strings come in the form "??? ?????". It's the questions. The database is not mine, I can't change it somehow. I can only read. Google didn't help. As I understand it, there is no set names in mssql. Where to prescribe collate did not figure it out. It seems to be needed for sorting, but I would just read a row in the table.
Made a request to INFORMATION_SCHEMA.COLUMNS. Returned the following parameters about this field:
'DATA_TYPE' => 'nvarchar'
'CHARACTER_SET_NAME' => string 'UNICODE'
'COLLATION_NAME' => string 'Latin1_General_CI_AI'
Working on php. I set up the connection like this:
$dbh = new PDO("dblib:host=hostname:port;dbname=db", "login", "pass");
SELECT TOP 100 * FROM Discounts;
Answer the question
In order to leave comments, you need to log in
dblib itself does not work well with Cyrillic, you need to constantly run the results through iconv, look for the desired locale, etc. Therefore, freeTDS is installed on the server, which can convert data on the fly.
The config specifies the connection:
[SERV_UTF8]
host = serv.site.ru
port = 1433
tds version = 8.0
client charset = UTF-8
$dbh = new PDO("dblib:host=SERV_UTF8;dbname=db", $username, $pw);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question