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

前端 未结 7 1760
轻奢々
轻奢々 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:14

    Follow these simple steps:

    1. Install the instance with "mixed mode"-enabled. If your unsure watch this - video starts at the right sequence. Maybe it's a good idea to watch it completely.

    2. change the db-config in '...ci/application/config/database.php'

      $active_group = 'default';
      $query_builder = TRUE;
      
      $db['default'] = array(
          'dsn' => '',
          'hostname' => 'localhost',
          'username' => 'sa', // <- use 'sa'
          'password' => 'THE_PASSWORD_YOU_SET_ON_INSTALL', // "mixed-mode"
          'database' => 'ci',
          'dbdriver' => 'sqlsrv',
      //  'dbdriver' => 'mysqli', // <- my old "non-server" config (approx. 70% slower)
          'dbprefix' => '',
          'pconnect' => FALSE,
          'db_debug' => (ENVIRONMENT !== 'production'),
          'cache_on' => FALSE,
          'cachedir' => '',
          'char_set' => 'utf8',
          'dbcollat' => 'utf8_general_ci',
          'swap_pre' => '',
          'encrypt' => FALSE,
          'compress' => FALSE,
          'stricton' => FALSE,
          'failover' => array(),
          'save_queries' => TRUE
      );
      

    0 讨论(0)
提交回复
热议问题