1
I am in a project using UBUNTU-SERVER 64bits as WEBSERVER. In the project I chose the Microsoft Sql Server 2012 database which I have a short-term license to use.
With a lot of effort I got the connection using some libs as freetds Sybase... for PHP-7. However I have character encoding error. I already set the UTF-8 parameter in the connection string and I did not succeed! Someone has already been through the same problem and managed to solve 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
);
The driver
sqlsrv
does not work? only thedblib
?– rray
sqlsrv is not supported by what I’ve searched for. http://stackoverflow.com/questions/10903148/ubuntu-php-and-sqlsrv-connect
– Rafael L Ramon
Changes the string
dblib:host ....
forsqlsrv:host ....
http://php.net/manual/en/ref.pdo-sqlsrv.connection.php and http://php.net/manualen/ref.pdo-dblib.php. In the worst case you can use ODBC.– rray
Message: Undefined class Constant 'SQLSRV_ENCODING_UTF8' Filename: /webserver/Development/system/database/drivers/Pdo/subdrivers/pdo_sqlsrv_driver.php<br /> Removing char-set A Database Error Occurred
– Rafael L Ramon
Did you change the dns? how did you do?
– rray
$db['default'] = array( 'dsn' = > 'sqlsrv:host=192.168.1.1:1433;dbname=TRANSOESTE', 'hostname' => 'sqlsrv:host=192.168.1.1:1433;dbname=TRANSOESTE', 'port' = > '1433', 'username' => 'sa', 'password' => '354263', 'database' => 'TRANSOESTE', 'dbdriver' => 'Pdo', 'dbprefix' => ', 'pconnect' => FALSE, 'db_debug' => (ENVIRONMENT !== 'Production'), 'cache_on' => FALSE, 'cachedir' => ', 'char_set' => ', 'dbcollat' => ', swap_pre' => ', 'Encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array(), 'save_queries' => TRUE );
– Rafael L Ramon
The base is utf-8 ? the php file too?
– rray
the database is like Latin1_general_ci_as <meta charset="utf-8"> php I’ll confirm but when I use mysql I don’t have this problem.
– Rafael L Ramon
I believe this is the problem, you can do a test, create a new database with Encode utf-8 and create a table and add some records and list in php and see if the problem with encoding continues.
– rray
Not the problem is really in the connected lib. I’m using the same database on another web server that runs the mssql lib and I don’t have this problem. php is ok too. was viewing on a website and it seems that this lib does not support utf-8 http://www.synet.sk/php/en/230-php-drivers-for-microsoft-sql-server-mssql-sqlsrv-utf8
– Rafael L Ramon
This is ajax Rafael?
– Guilherme Nascimento
No. This is the framework connection configuration array.
– Rafael L Ramon