Cakephp Sqlserver 编码

时间:2023-03-21
本文介绍了Cakephp Sqlserver 编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我很难过.我正在尝试为我的 Sqlserver 连接设置编码,但我尝试的所有方法都失败了.我只得到

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

错误:使用Sqlserver"的数据库连接丢失或无法连接连接.
数据库服务器返回此错误:SQLSTATE[IMSSP]: 指定的编码无效SQLSRV_ATTR_ENCODING.

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:

错误:SQLSTATE[IMSSP]:翻译查询字符串时发生错误到 UTF-16:目标中不存在 Unicode 字符的映射多字节代码页.

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.

SQL 版本为 2008 R2
Cakephp 版本:2.4.2
PHP 版本:5.3.27

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
);

这篇关于Cakephp Sqlserver 编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:CakePHP 2.3 - 单元测试用户登录 下一篇:intl PHP 扩展不适用于 xampp 服务器

相关文章

最新文章