我通过Linux系统上的mdbtools连接到Access数据库,并通过Active Record运行任何查询,它返回一个空结果。没有错误或日志中显示的任何内容。有任何想法吗 ?它连接到数据库没有任何障碍,我可以使用默认的PHP方法访问表或运行查询(例如odbc_exec(...))。
数据库连接如下所示:
$db['access']['hostname'] = 'MyDB';
$db['access']['username'] = '';
$db['access']['password'] = '';
$db['access']['database'] = 'MyDB';
$db['access']['dbdriver'] = 'odbc';
$db['access']['dbprefix'] = '';
$db['access']['pconnect'] = TRUE;
$db['access']['db_debug'] = TRUE;
$db['access']['cache_on'] = FALSE;
$db['access']['cachedir'] = '';
$db['access']['char_set'] = 'utf8';
$db['access']['dbcollat'] = 'utf8_general_ci';
$db['access']['swap_pre'] = '';
$db['access']['autoinit'] = TRUE;
$db['access']['stricton'] = FALSE;
odbc.ini看起来像:
[MyDB]
Description = My Database
Driver = /usr/lib64/libmdbodbc.so
Database = /var/database/MyDB.mdb
连接:
$this->access = $this->load->database('access', TRUE);
答案 0 :(得分:0)
我没有使用以下配置进行测试的microsoft access数据库,但我认为这应该可以让您体验不同的配置。您可以在配置中指定data source name,我从codeigniter forum收集设置并与您合并。
$db['access']['hostname'] = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=/var/database/MyDB.mdb";
$db['access']['username'] = "ADODB.Connection";
$db['access']['password'] = "";
$db['access']['database'] = "/var/database/MyDB.mdb";
$db['access']['dbdriver'] = "odbc";
$db['access']['dbprefix'] = "";
$db['access']['pconnect'] = TRUE;
$db['access']['db_debug'] = TRUE;
$db['access']['cache_on'] = FALSE;
$db['access']['cachedir'] = "";
$db['access']['char_set'] = "utf8";
$db['access']['dbcollat'] = "utf8_general_ci";
$db['access']['swap_pre'] = "";
$db['access']['autoinit'] = TRUE;
$db['access']['stricton'] = FALSE;