我正在尝试将 Microsoft Access 数据库用于我正在考虑在 CodeIgniter 或 CakePHP 中进行的演示项目。忽略使用 Microsoft Access 的可能愚蠢之处,我无法准确地弄清楚连接字符串如何与框架的数据库设置相对应。在直接 PHP 中,我可以使用此代码连接到 Access 数据库:
$db_connection = odbc_connect(
"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\\path\\to\\db.mdb",
"ADODB.Connection", "", "SQL_CUR_USE_ODBC"
);
这些字符串如何与 Code Igniter db 设置相对应?这似乎不太有效:
$db['access']['hostname'] = "{Microsoft Access Driver (*.mdb)}";
$db['access']['username'] = "ADODB.Connection";
$db['access']['password'] = "";
$db['access']['database'] = "\\path\\to\\db.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";