DBLIB PDO AND UTF-8 CODING

1

I'm in a project using 64bit UBUNTU-SERVER as WEBSERVER. In the project I chose the database Microsoft Sql Server 2012 which I have a use license acquired shortly.

With much effort I got the connection using some libs like sybase freetds ... for PHP-7. But I'm having a character encoding error. I have already set the UTF-8 parameter in the connection string and I did not succeed! Has anyone had the same problem and solved it?

$db['default'] = array(
    'dsn'      => 'dblib:host=192.168.1.1:1433;dbname=TOESTE;charset=UTF-8',
    'hostname' => 'dblib:host=192.168.1.1:1433;dbname=TOESTE;charset=UTF-8',
    'port'     => '1433',
    'username' => 'sa',
    'password' => 'xxxxxx',
    'database' => 'TOESTE',
    'dbdriver' => 'pdo',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt'  => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);
    
asked by anonymous 24.02.2016 / 18:21

1 answer

3

I do not know if they have solved this problem, but I will leave here a possible solution:

The default installation of freetds uses version 4.2 of the TDS that should work for all versions of SQL Server. The problem here is that this version does not support UTF-8 characters or accents of any kind. To correct this you can enter the TDS version in the connection DSN:

dblib:version=7.0;charset=UTF-8;host=domain.example.com;dbname=example;

Or change the file freetds.conf , in setting [global] to tds version , put the correct version according to the version of SQL that you are using. To know the correct version, take a look here:

link

    
30.12.2016 / 00:13