Entity anlegen: hook_entity_info search...

function aktionen_entity_info() {
  return array(
    'aktionen' => array(
      'label' => t('Actions'),
      'base table' => 'aktionen',
      // overwrite controller for DB access
      'controller class' => 'AktionenController',
      'entity keys' => array(
        'id' => 'aid',
        'label' => 'label',
      ),
      'static cache' => FALSE,
    ),
  );
}

Überschreibe Controler für den Zugriff auf externe Datenbank

class AktionenController extends DrupalDefaultEntityController {
 
  protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
    // set (Database)$activeKey to 'extern'
    $old_key = Database::setActiveConnection('extern');
    // build the query on the extern-DB
    $query = parent::buildQuery($ids, $conditions, $revision_id);
    // reset $activeKey
    Database::setActiveConnection($old_key);
    return $query;
  }
 
}
aufgaben/db_extern/entity.txt · Zuletzt geändert: 2022/06/06 15:13 von 127.0.0.1
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki