Cakephp Sqlserver encoding

cakephp, php, sql-server

Solution

After a lot of trial and error this works:

public $default = array(
    'datasource'    => 'Database/Sqlserver',
    'persistent'    => false,
    'host'      => 'localhost',
    'login'     => 'sa',
    'password'  => 'password',
    'database'  => 'SchedulingDatabase',
    'encoding'  => PDO::SQLSRV_ENCODING_UTF8
);

Problem

This has me stumped. I am trying to set encoding for my Sqlserver connection and all that I have tried has failed. I only get Error: A Database connection using "Sqlserver" was missing or unable to connect. The database server returned this error: SQLSTATE[IMSSP]: An invalid encoding was specified for SQLSRV_ATTR_ENCODING. The original error I was trying to solve through encoding is: Error: SQLSTATE[IMSSP]: An error occurred translating the query string to UTF-16: No mapping for the Unicode character exists in the target multi-byte code page. The SQL version is 2008 R2 Cakephp Version: 2.4.2 PHP Version: 5.3.27

Original source