gpt4 book ai didi

php - Zend pgsql 连接错误

转载 作者:行者123 更新时间:2023-11-29 00:12:46 25 4
gpt4 key购买 nike

连接 zend 和 pgsql 时出现以下错误早些时候我的程序在 mysql 中运行良好

Array ( [host]     => localhost 
[username] => openerp
[password] => postgresql
[dbname] => projects_display
[adapter] => PDO_PGSQL )
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] invalid connection option "adapter"' in /var/www/projects/display/display_res/library/Zend/Db/Adapter/Pdo/Abstract.php:129 Stack trace: #0 /var/www/projects/display/display_res/library/Zend/Db/Adapter/Pdo/Abstract.php(129): PDO->__construct('pgsql:host=loca...', 'openerp', 'postgresql', Array) #1 /var/www/projects/display/display_res/library/Zend/Db/Adapter/Pdo/Pgsql.php(87): Zend_Db_Adapter_Pdo_Abstract->_connect() #2 /var/www/projects/display/display_res/library/Zend/Db/Adapter/Abstract.php(860): Zend_Db_Adapter_Pdo_Pgsql->_connect() #3 /var/www/projects/display/display_res/library/Zend/Db/Adapter/Pdo/Pgsql.php(171): Zend_Db_Adapter_Abstract->quote('tbl_user_groups') #4 /var/www/projects/display/display_res/library/Zend/Db/Table/Abstract.php(835): Zend_Db_Adapter_Pdo_Pgsql->describeTable('tbl_user_groups', NULL) #5 /var/www/projects/display/display_res/library/Zend/Db/Table/Abstract.php(874): Zend_Db_Table_Abstract->_setupMetadata() #6 /var in /var/www/projects/display/display_res/library/Zend/Db/Adapter/Pdo/Abstract.php on l
protected function _initDb()
{

$config = $this->getOptions();

//print_r($config);
// db stuff here
$parameters =array(
'host' => $config['resources']['db']['params']['host'],
'username' => $config['resources']['db']['params']['username'],
'password' => $config['resources']['db']['params']['password'],
'dbname' => $config['resources']['db']['params']['dbname'],
'adapter' => $config['resources']['db']['adapter']
);
print_r($parameters);
echo "<br>";
try {
$db = Zend_Db::factory($config['resources']['db']['adapter'], $parameters);
$db->getConnection();
} catch (Zend_Db_Adapter_Exception $e) {

} catch (Zend_Exception $e) {
}
Zend_Db_Table::setDefaultAdapter($db);


}

最佳答案

在将数组作为第二个参数传递给 Zend_Db::factory 之前删除 $parameters['adapter']:

...
try {
unset($parameters['adapter']);
$db = Zend_Db::factory($config['resources']['db']['adapter'], $parameters);
$db->getConnection();
}
...

关于php - Zend pgsql 连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24279266/

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