如何在 CodeIgniter 中连接到 SQL Server 数据库?
如何在 CodeIgniter 中连接到 SQL Server 数据库?
How do I connect to a SQL Server database in CodeIgniter?
我目前正在 CodeIgniter 中启动一个应用程序,我想使用 SQL Server.
I'm currently starting an application in CodeIgniter and I would like to use SQL Server.
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = '#.#.#.27';
$db['default']['username'] = '@@@@@@';
$db['default']['password'] = '@@@@@@@@@';
$db['default']['database'] = '$$$$$$$$$$$$$';
$db['default']['dbdriver'] = 'mssql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$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;
自动加载数据库后,它只显示一个没有错误的空白页面.您能否告诉我要使用 SQL Server 数据库还需要进行哪些其他更改?
After auto-loading the database, it shows just a blank white page with no errors. Can you please tell me what other changes I have to make to work with the SQL Server database?
#autoload.php#
$autoload['libraries'] = array('database');
推荐答案
我无法让它与 mssql
的 supported 驱动程序一起工作,所以我使用了 sqlsrv
I couldn't get it to work with the supported driver of mssql
so I used sqlsrv
我通常使用 ip,port 作为 hostname
连接,所以我改变了它.
I normally connect with ip,port as the hostname
, so I changed that.
pconnect
也给我带来了问题.我将它设置为 FALSE
并开始工作.
pconnect
was also giving me issues. I set it to FALSE
and it started working.
这是我要工作的配置:
$db['default']['hostname'] = '127.0.0.1,1433';
$db['default']['username'] = 'username1';
$db['default']['password'] = 'secretpassword';
$db['default']['database'] = 'databasename';
$db['default']['dbdriver'] = 'sqlsrv';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
相关文章