Because of the comparison between MSSQL and MySQL data, so.
Configuration:
database.php
$db['default']['hostname'] = '192.168.1.222';$db['default']['username'] = 'root';$db['default']['password'] = 'test';$db['default']['database'] = 'demo_database';$db['default']['dbdriver'] = 'mysql';$db['default']['dbprefix'] = 'iwebshop_';$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;$db['default']['hostname'] = '192.168.1.222';$db['default']['username'] = 'sa';$db['default']['password'] = 'test';$db['default']['database'] = 'demo_database';$db['default']['dbdriver'] = 'sqlsrv';$db['default']['dbprefix'] = '';$db['default']['pconnect'] = TRUE;$db['default']['char_set'] = 'utf-8';
Just don't know how to call?
Reply content:
Because of the comparison between MSSQL and MySQL data, so.
Configuration:database.php
$db['default']['hostname'] = '192.168.1.222';$db['default']['username'] = 'root';$db['default']['password'] = 'test';$db['default']['database'] = 'demo_database';$db['default']['dbdriver'] = 'mysql';$db['default']['dbprefix'] = 'iwebshop_';$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;$db['default']['hostname'] = '192.168.1.222';$db['default']['username'] = 'sa';$db['default']['password'] = 'test';$db['default']['database'] = 'demo_database';$db['default']['dbdriver'] = 'sqlsrv';$db['default']['dbprefix'] = '';$db['default']['pconnect'] = TRUE;$db['default']['char_set'] = 'utf-8';
Just don't know how to call?
In the model call for example $db = $this->load->database (' Default ', TRUE);
$db->query ($sql);
The above configuration file is wrong, two different databases need to be separated, cannot use the same key name default, otherwise the subsequent configuration will overwrite the previous configuration. The code above is to choose a different database configuration based on the key name.
$db1=$this->load->database('default',TRUE);$db2=$this->load->database('another',TRUE);
No longer available when multiple databases are called$this->db->query($sql);
can only be used$db1->query($sql);
By default, you can use it directly using the $this->db.
For the second, you need to change the name of the default to identify their configuration, so you can use the
$db 2= $this->load->database (' another ', TRUE);
To invoke