Welcome Guest, Not a member yet? Register   Sign In
code igniter and ms access

I'm trying to use Microsoft Access as the db for a demo project that I'm thinking of doing in Code Igniter. Ignoring the possible folly of using MS Access, I haven't been able to figure out precisely how the connection string corresponds to the framework's db settings. In straight php, I can use this code to connect to an access db:

$db_connection = odbc_connect(
  "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\\path\\to\\db.mdb",
  "ADODB.Connection", "", "SQL_CUR_USE_ODBC"

How do those strings correspond to the Code Igniter db settings? This doesn't seem to be quite working (though it's not exactly throwing an error, either):

$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";

Oh, BTW, I'm running a xampp install of apache under xp if that matters.

Ok, I figured out that it should be something like:

$db['default']['hostname'] = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:/path/to/db.mdb";
$db['default']['username'] = "ADODB.Connection";
$db['default']['password'] = "";
$db['default']['database'] = "C:/path/to/db.mdb";
$db['default']['dbdriver'] = "odbc";
$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";

However, I seem to have run into some bugs in the system. I can tell that it's using CI_DB_odbc_driver->db_connect() to connect to the db, which is located in system/database/drivers/odbc/odbc_driver.php. For whatever reason, the $this object in there doesn't seem to have any of the settings from database.php in it, so I have to re-add them there to get it to work. I also have to add $this->db->dbdriver = "odbc"; to my controller right after the $this->load->database(); call.

Theme © iAndrew 2016 - Forum software by © MyBB