0

When a 404 override caused by nonexistent action (only action, not controller) is being handled by Codeigniter, the datamapper fails to load, thus causing any database functionality impossible.

My usage case is: I want to register data about who/when/where encountered a 404 on the site.

Version info: codeigniter 2.1.0; datamapper 1.8.2

Slavic
  • 1,891
  • 2
  • 16
  • 27

1 Answers1

0

I figured the problem is in the way datamapper "extends" the db class. The file that defines the name of the db class to use is only included once, thus when the codeigniter object is re-constructed, the name remains un-overridden. To fix this, at your own expense, you have to hack the datamapper files.

File "application/third_party/datamapper/system/DB.php" after line 143:

// load Datamappers DB interceptor class
require_once(APPPATH.'third_party/datamapper/system/DB_driver.php');

put these lines:

// HACK to make datamapper load correctly after codeigniter has been reconstructed in
// cases of invalid actions (404 overrides)
$driver = 'DM_DB_Driver';
Slavic
  • 1,891
  • 2
  • 16
  • 27