gpt4 book ai didi

php - 数据未插入生产站点的数据库

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

我的数据没有插入到生产站点的数据库中,而它在我的本地测试站点上运行正常。我的 codeigniter 配置是正确的。如果我在数据库中手动执行查询,它会显示正确的消息,并且数据会插入到数据库中。*)当我打印查询时,它也符合预期。

我认为这是服务器配置问题。我正在使用 go daddy 和 mysql。

数据库配置:

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'etc';
$db['default']['password'] = 'etc';
$db['default']['database'] = 'ieshopif_y';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = FALSE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

*) 手动执行查询后,我收到此成功消息:

Connecting to database: ieshopif_y
Connected OK:file: /home/ieshopif/public_html/application/config/database.php Line: 82

如果是数据库问题,我想知道如何配置数据库才能使其正常工作。

最佳答案

这些选项在生产、开发和测试中可能有所不同:

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'etc';
$db['default']['password'] = 'etc';
$db['default']['database'] = 'ieshopif_y';

我建议您将其与在 index.php 上定义的 ENVIRONMENT 常量分开,因为 hostname 在生产服务器中可能不同。试试这个:

if (defined('ENVIRONMENT')) {
switch (ENVIRONMENT) {
case 'development':
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'username';
$db['default']['password'] = 'password';
$db['default']['database'] = 'ieshopif_y';
break;

case 'testing':
case 'production':
$db['default']['hostname'] = 'domain.com';
$db['default']['username'] = 'root';
$db['default']['password'] = 'secure_pass';
$db['default']['database'] = 'ieshopif_y';
break;

default:
exit('The application environment is not set correctly.');
}
}

关于php - 数据未插入生产站点的数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17888305/

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