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
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
);
Tried this out with Cakephp 3.0 seems to work nicely.
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Sqlserver',
'persistent' => false,
'host' => 'localhost',
'port' => '1433', //using this port
'username' => 'sa',
'password' => 'password',
'database' => 'cake_bookmarks',
'encoding' => PDO::SQLSRV_ENCODING_UTF8,
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With