我尝试使用cake php 2.8.6和sqlserver 2016设置quickapp -cms和croogo-cms。它与mysql一起工作正常,但与sql server失败了。我遇到以下错误:
cake php 2.8.6
php 5.6.23
Ms sql server
Microsoft SQL Server Management Studio 13.0.15700.28
Microsoft Analysis Services Client Tools 13.0.1700.68
Microsoft Data Access Components (MDAC) 6.2.9200.16384
Microsoft MSXML 3.0 6.0
Microsoft Internet Explorer 9.10.9200.17607
Microsoft .NET Framework 4.0.30319.42000
Operating System 6.2.9200
====================================================================================
Unable to connect to database, please check your information. Details:
Connection to database could not be established: SQLSTATE[IMSSP]: An invalid encoding was specified for SQLSRV_ATTR_ENCODING.
================================================================================
我的数据库配置:
'datasource' => 'Database/Sqlserver',
'persistent' => false,
'host' => 'COLLONMADE\SQLEXPRESS',
'login' => 'sa',
'password' => 'root',
'database' => 'cro',
'prefix' => '',
'encoding' => 'utf8',
答案 0 :(得分:0)
最后我找到了不是最佳的解决方案我认为但在我的情况下有效。谢谢大家回答这个问题。我用croogo cms版本1.4.3和1.5.8尝试过这两种方法都很完美。
转到myapp \ lib \ Cake \ Model \ Datasource \ Database \ Sqlserver.php
并注释掉标记行,如下所示:
/*$flags = array(
PDO::ATTR_PERSISTENT => $config['persistent'],
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
);
if (!empty($config['encoding'])) {
$flags[PDO::SQLSRV_ATTR_ENCODING] = $config['encoding'];
}*/
try {
$this->_connection = new PDO(
"sqlsrv:server={$config['host']};Database={$config['database']}",
$config['login'],
$config['password']
//$flags
);
在此更改之后,您将能够进入下一步,在croogo中您将收到内部服务器错误,这是因为它尚未创建设置表,因此请转到:
config/schema/sql/croogo.sql
并复制插入查询设置表并在数据库中执行。
现在再次进入安装程序,您将能够完成所有步骤并登录。