简体   繁体   English

cakephp 2.2.2与mssql sql server的数据库连接

[英]cakephp 2.2.2 database connection with mssql sql server

I am trying to connect CakePHP 2.2.2 stable version with MS SQL database. 我正在尝试将CakePHP 2.2.2稳定版本与MS SQL数据库连接。

Below is db connection that I'm using: 下面是我正在使用的数据库连接:

public $default = array(
    'datasource' => 'Database/Mssql',
    'persistent' => false,
    'host' => '192.192.1.1',
    'login' => 'username',
    'password' => 'password',
    'database' => 'dbname',
    'prefix' => '',
    //'encoding' => 'utf8',
);

When I connect with CorePHP - it works, So all credentials I use are correct however when I connect with CakePHP 2.2.2 version, returns below error: 当我连接CorePHP - 它工作,所以我使用的所有凭据都是正确的但是当我连接CakePHP 2.2.2版本时,返回以下错误:

Cake is NOT able to connect to the database.
Datasource class Mssql could not be found.

I have following files in my dbo library on path: cakephp/lib/Cake/Model/Datasource/Database 我在路径上的dbo库中有以下文件: cakephp/lib/Cake/Model/Datasource/Database

Mysql.php
Postgres.php
Sqlite.php
Sqlserver.php

So I believe that all files required for MS SQL Server connection is present in my Cake version. 所以我相信MS SQL Server连接所需的所有文件都存在于我的Cake版本中。

Let me know what I am missing or having problem with. 让我知道我错过了什么或有问题。

Thanks in advance ! 提前致谢 !

我认为正确的数据源字符串是'Sqlserver'而不是'mssql'。

The Sqlserver datasource depends on Microsoft’s PHP extension called pdo_sqlsrv. Sqlserver数据源依赖于Microsoft的 PHP扩展名为pdo_sqlsrv。 This PHP Extension is not included in the base installation of PHP and must be installed separately. 此PHP扩展不包含在PHP的基本安装中,必须单独安装。

Also the SQL Server Native Client must be installed for the extension to work. 此外,必须安装SQL Server Native Client才能使扩展工作。 As the Native Client is available only for Windows you will not be able to install it on Linux, Mac OS X or FreeBSD. 由于Native Client 仅适用于Windows ,因此无法在Linux,Mac OS X或FreeBSD上安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM