How do I connect to a SQL Server database in CodeIgniter?

前端 未结 7 1762
轻奢々
轻奢々 2020-12-30 17:17

How do I connect to a SQL Server database in CodeIgniter?

I\'m currently starting an application in CodeIgniter and I would like to use SQL Server.

$         


        
7条回答
  •  春和景丽
    2020-12-30 18:04

    I couldn't get it to work with the supported driver of mssql so I used sqlsrv

    I normally connect with ip,port as the hostname, so I changed that.

    pconnect was also giving me issues. I set it to FALSE and it started working.

    Here is the configuration I got to work:

    $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;
    

提交回复
热议问题