title: Codeigniter Datamapper Cross-Database Joins
body: <p>Good morning,</p>
  
  <p>I am currently working on a project that utilises Codeigniter and the Datamapper Library (http://datamapper.wanwizard.eu). The project uses a central database for user data (called "base") and a seperate database for the application data ("crm"). This is so that in the future, we may build other applications that use the user directory without being tied to a single server.</p>
  
  <p>I have a problem in that I need to use the built in Datamapper relationships but across the two databases. Here is my setup so far:</p>
  
  <p><strong>Person Model</strong></p>
  
  <pre><code>class person extends DataMapper {
  
      var $db_params = 'base';
      var $prefix = 'base_';
  
      var $has_many = array(
          'initiated_event' =&gt; array('class' =&gt; 'event','other_field' =&gt; 'initiator')
      )
  
  }
  </code></pre>
  
  <p><strong>Event Model</strong></p>
  
  <pre><code>class event extends DataMapper {
  
      var $db_params = 'crm';
      var $prefix = 'crm_';
  
      var $has_one = array(
          'initiator' =&gt; array('class' =&gt; 'person','other_field' =&gt; 'initiated_event')
      )
  
  }
  </code></pre>
  
  <p><strong>The Problem</strong></p>
  
  <p>When I attempt to use <em>$events->initiator->get()</em>, I get the following error:</p>
  
  <pre><code>Error Number: 1146
  Table 'circle_base.crm_events' doesn't exist
  SELECT `base_persons`.* FROM (`base_persons`) LEFT OUTER JOIN `crm_events` initiated_event_crm_events ON `base_persons`.`id` = `initiated_event_crm_events`.`initiator_id` WHERE `initiated_event_crm_events`.`id` = 1
  Filename: C:\xampp\htdocs\circle\crm\system\database\DB_driver.php
  Line Number: 330
  </code></pre>
  
  <p>Could anybody shed some light on the matter? Does DataMapper actually support cross-database joins. If not, is there any way that I can achieve this?</p>