Codeigniter using ms access database

前端 未结 7 1243
梦如初夏
梦如初夏 2020-12-10 05:01

So I using access database(*mdb). This my code and success to connect:

$db[\'test\'][\'hostname\'] = \'Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\blabl         


        
7条回答
  •  生来不讨喜
    2020-12-10 05:43

    After many searches (nothing from the mentioned solution worked) I found a different solution, on some ms Access db's you can only connect using double slashes in the connection string (not in the database path):

    $db['test']['hostname'] = 'Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\path\\to\my.mdb';
    $db['test']['username'] = '';
    $db['test']['password'] = '';
    $db['test']['database'] = 'Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\path\to\my.mdb';
    $db['test']['dbdriver'] = 'odbc';
    $db['test']['dbprefix'] = '';
    $db['test']['pconnect'] = TRUE;
    $db['test']['db_debug'] = TRUE;
    $db['test']['cache_on'] = FALSE;
    $db['test']['cachedir'] = '';
    $db['test']['char_set'] = 'utf8';
    $db['test']['dbcollat'] = 'utf8_general_ci';
    $db['test']['swap_pre'] = '';
    $db['test']['autoinit'] = TRUE;
    $db['test']['stricton'] = FALSE;
    

    not sure what is the cause because I was able to connect on some Access db's (same server, same folder, same Access version) using single slashes and double slashes didn't work, think it's a silly joke of the same guy who worked on IE :-(

提交回复
热议问题