我能夠連接到我的Linux機器上的用戶DSN(使用ODBC)。如何使用codeigniter連接到用戶DSN?
如何使用代碼點火器進行連接?
在我database.php中我有默認的數據庫:
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'user';
$db['default']['password'] = 'pass';
$db['default']['database'] = 'db_main';
$db['default']['dbdriver'] = 'mysql';
$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;
但是我還需要使用ODBC同時連接到另一個數據庫:
所以,我在我的控制器:
public function index()
{
$dsn = 'NZSQL://someuser:[email protected]/somedatabase';
$this->load->database($dsn);
$this->db->query("SELECT * FROM Cust Limit 10");
$result = $this->db->result();
}
我得到錯誤:
A Database Error Occurred
Error Number: 1146
Table 'db_main.Cust' doesn't exist
SELECT * FROM Cust Limit 10
Filename: /var/www/controllers/netezzatest.php
Line Number: 28