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

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

    it is the same process as mysql. use the same configuration given below:

    $active_group = 'default'; $active_record = TRUE;

    $db['default']['hostname'] = 'xxx.xx.xx.xx\SQLEXPRESS';

    $db['default']['username'] = 'sa';

    $db['default']['password'] =

    'xxxxxxx'; $db['default']['database'] = 'xxxxx';

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

    In your Model use same as

    function selectagent($table,$agent) {

    $field = $this->db->get_where($table, array('var1' =>$agent,'day(date)'=>date('d')));

      $fields=$field->result();
    
      return $fields;
    }
    

提交回复
热议问题