gpt4 book ai didi

sql-server - cakephp 2.0.5 Sqlserver 需要数据库连接

转载 作者:太空宇宙 更新时间:2023-11-04 11:34:30 24 4
gpt4 key购买 nike

我正在尝试在 Linux 上使用 cakephp 2.0.5 访问第二个 MS SQL 数据库。

我在 Config/database.php 中设置了一个 Sqlserver 数据源

public $msdb = array(

'datasource' => 'Database/Sqlserver',

'persistent' => false,

'host' => 'xxx.xxx.xxx.xxx',

'port' => '1433',

'login' => 'username',

'password' => 'password',

'database' => 'DB',

'prefix' => '',

);

但是我得到这个错误:

Missing Database Connection

Error: Sqlserver requires a database connection

Error: Confirm you have created the file : app/Config/database.php.

Notice: If you want to customize this error message, create app/View/Errors/missing_connection.ctp.

堆栈跟踪

#0 /var/www/html/modip/cakephp-cakephp-6864406/lib/Cake/Model/ConnectionManager.php(101): DboSource->__construct(Array)

#1 /var/www/html/modip/cakephp-cakephp-6864406/lib/Cake/Model/Model.php(3234): ConnectionManager::getDataSource('msdb')

#2 /var/www/html/modip/cakephp-cakephp-6864406/lib/Cake/Model/Model.php(1030): Model->setDataSource('msdb')

#3 /var/www/html/modip/cakephp-cakephp-6864406/lib/Cake/Model/Model.php(3258): Model->setSource('PERSON')

#4 /var/www/html/modip/cakephp-cakephp-6864406/lib/Cake/Model/Model.php(2483): Model->getDataSource()

#5 /var/www/html/modip/cakephp-cakephp-6864406/lib/Cake/Controller/Component/PaginatorComponent.php(172): Model->find('all', Array)

#6 /var/www/html/modip/cakephp-cakephp-6864406/lib/Cake/Controller/Controller.php(1025): PaginatorComponent->paginate(NULL, Array, Array)

#7 /var/www/html/modip/app/Controller/PersonsController.php(7): Controller->paginate()

#8 [internal function]: PersonsController->index()

#9 /var/www/html/modip/cakephp-cakephp-6864406/lib/Cake/Controller/Controller.php(473): ReflectionMethod->invokeArgs(Object(PersonsController), Array)

#10 /var/www/html/modip/cakephp-cakephp-6864406/lib/Cake/Routing/Dispatcher.php(104): Controller->invokeAction(Object(CakeRequest))

#11 /var/www/html/modip/cakephp-cakephp-6864406/lib/Cake/Routing/Dispatcher.php(86): Dispatcher->_invoke(Object(PersonsController), Object(CakeRequest), Object(CakeResponse))

#12 /var/www/html/modip/app/webroot/index.php(96): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))

#13 {main}

在 cakephp 之外,我可以毫无问题地访问它

mssql_connect("ip_addr:1433", $user, $pass);

还有什么我应该做的吗?

我又调试了一下,发现它失败了

lib/Cake/Model/Datasource/Database/Sqlserver.php 中

public function enabled() {

return in_array('sqlsrv', PDO::getAvailableDrivers());

}

PDO驱动中没有sqlsrv。如果我从各种文档中正确理解,

sqlsrv 适用于 Windows。

我如何将它用于 linux?

谢谢

最佳答案

我也遇到了这个错误,这很误导人。我最终发现用户 [在您的案例中为“用户名”] 没有足够的权限访问数据库 [在您的案例中为“DB”]

关于sql-server - cakephp 2.0.5 Sqlserver 需要数据库连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8984774/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com