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

4

1 回答 1

0

我认为问题在于 datamapper “扩展” db 类的方式。定义要使用的 db 类的名称的文件只包含一次,因此当重新构造 codeigniter 对象时,该名称保持未被覆盖。要解决此问题,您必须自费破解数据映射器文件。

第 143 行之后的文件“application/third_party/datamapper/system/DB.php”:

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

把这些行:

// HACK to make datamapper load correctly after codeigniter has been reconstructed in
// cases of invalid actions (404 overrides)
$driver = 'DM_DB_Driver';
于 2012-06-14T10:33:47.463 回答