On latest version of 8.x-3.x branch i get following error when try to add a view for contribution page

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'civicrmdb.civicrm_contribution_page' doesn't exist: SELECT civicrm_contribution_page.id AS id FROM {civicrm_contribution_page} civicrm_contribution_page LIMIT 11 OFFSET 0; Array ( )

views for Contact, Contribution, Event works fine but not incase of Contribution page, Payment processor, campaign etc.

Can we create list of contribution pages/campaigns/payment processors using civicrm_entity + civicrm views d8?

1 Answer 1


This happens when you have separate database for civicrm tables. Below patch in civicrm_entity module fixes problem for 'Base table or view not found:'

diff --git a/src/CivicrmEntityViewsData.php b/src/CivicrmEntityViewsData.php
index 51db201..ffbb31d 100644
--- a/src/CivicrmEntityViewsData.php
+++ b/src/CivicrmEntityViewsData.php
@@ -17,6 +17,8 @@ class CivicrmEntityViewsData extends EntityViewsData {
     $base_table = $this->entityType->getBaseTable() ?: $this->entityType->id();
     $base_field = $this->entityType->getKey('id');

+    $database = _civicrm_get_db_config()['key'];
     // Setup base information of the views data.
     $data[$base_table]['table']['group'] = sprintf('%s (CiviCRM Entity)', $this->entityType->getLabel());
     $data[$base_table]['table']['provider'] = $this->entityType->getProvider();
@@ -27,6 +29,7 @@ class CivicrmEntityViewsData extends EntityViewsData {
       'field' => $base_field,
       'title' => $this->entityType->getLabel(),
       'cache_contexts' => $this->entityType->getListCacheContexts(),
+      'database' => $database,
     $data[$base_table]['table']['entity revision'] = FALSE;
     if ($label_key = $this->entityType->getKey('label')) {
  • We've been using the same "CMS Database Integration" code that would go into the Drupal settings.php as was in D7 but perhaps this is better. Will check it out. Jan 28, 2020 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.