Hello Folks, 

I have been trying to integrate views with CIVICRM data in my backdropcms site, but failed. I followed the backdropcms documentation https://docs.civicrm.org/sysadmin/en/latest/integration/backdrop/views following all mentioned steps but its showing me SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xxxx.civicrm_event' doesn't exist. Please note that i have separated backdrop and civicrm databases where xxx is the db prefix for backdrop database. 

Please help me. Thanks in advance!

Rajib Paul

Comments

Hi laryn, 

Thanks for your reply. Unfortunately not. I followed every single steps but did not work! 

Here is my civicrm.settings.php



<?php

global $civicrm_root, $civicrm_setting, $civicrm_paths;

if (!defined('CIVICRM_UF')) {
  if (getenv('CIVICRM_UF')) {
    define('CIVICRM_UF', getenv('CIVICRM_UF'));
  }
  else {
    define('CIVICRM_UF', 'Backdrop');
  }
}

...

if (!defined('CIVICRM_UF_DSN') && CIVICRM_UF !== 'UnitTests') {
  define( 'CIVICRM_UF_DSN'           , 'mysql://<USER>:<PASSWORD>@localhost/<DBNAME>?new_link=true%%CMSdbSSL%%');
}

// 

if (!defined('CIVICRM_DSN')) {
  if (CIVICRM_UF === 'UnitTests' && isset($GLOBALS['_CV']['TEST_DB_DSN'])) {
    define('CIVICRM_DSN', $GLOBALS['_CV']['TEST_DB_DSN']);
  }
  else {
    define('CIVICRM_DSN', 'mysql://<USERNAME>:<PASSWORD>@localhost:3306/<CIVICRM_DBNAME>?new_link=true%%dbSSL%%');
  }
}

// define ('DB_DSN_MODE', 'auto');

if (!defined('CIVICRM_LOGGING_DSN')) {
  define('CIVICRM_LOGGING_DSN', CIVICRM_DSN);
}

global $civicrm_root;

$civicrm_root = '/var/www/backdrop/tcog2/local/src/modules/civicrm';
if (!defined('CIVICRM_TEMPLATE_COMPILEDIR')) {
  define( 'CIVICRM_TEMPLATE_COMPILEDIR', '/var/www/backdrop/PROJECTNAME/local/src/files/civicrm/templates_c/');
}

//if (!defined('CIVICRM_TEMPLATE_COMPILE_CHECK')) {
//  define( 'CIVICRM_TEMPLATE_COMPILE_CHECK', FALSE);
//}

if (!defined('CIVICRM_UF_BASEURL')) {
  define( 'CIVICRM_UF_BASEURL'      , 'http://BASEURL/');
}

 // Override the Temporary Files directory.
 // $civicrm_setting['domain']['uploadDir'] = '/path/to/upload-dir' ;

 // Override the custom files upload directory.
 // $civicrm_setting['domain']['customFileUploadDir'] = '/path/to/custom-dir';

 // Override the images directory.
 // $civicrm_setting['domain']['imageUploadDir'] = '/path/to/image-upload-dir' ;

 // Override the custom templates directory.
 // $civicrm_setting['domain']['customTemplateDir'] = '/path/to/template-dir';

 // Override the Custom php path directory.
 // $civicrm_setting['domain']['customPHPPathDir'] = '/path/to/custom-php-dir';

 // Override the extensions directory.
 // $civicrm_setting['domain']['extensionsDir'] = '/path/to/extensions-dir';

 // Override the resource url
 // $civicrm_setting['domain']['userFrameworkResourceURL'] = 'http://example.com/example-resource-url/';

 // Override the Image Upload URL (System Settings > Resource URLs)
 // $civicrm_setting['domain']['imageUploadURL'] = 'http://example.com/example-image-upload-url';

 // Override the Custom CiviCRM CSS URL
 // $civicrm_setting['domain']['customCSSURL'] = 'http://example.com/example-css-url' ;

 // Override the extensions resource URL
 // $civicrm_setting['domain']['extensionsURL'] = 'http://example.com/pathtoextensiondir'

 // Disable display of Community Messages on home dashboard
 // $civicrm_setting['domain']['communityMessagesUrl'] = false;

 // Disable automatic download / installation of extensions
 // $civicrm_setting['domain']['ext_repo_url'] = false;

 // set triggers to be managed offline per CRM-18212
 // $civicrm_setting['domain']['logging_no_trigger_permission'] = 1;

 // Override the CMS root path defined by cmsRootPath.
 // define('CIVICRM_CMSDIR', '/path/to/install/root/');

 // Opt-out of announcements by the CiviCRM core team for releases, paid services, events, etc. Separate each preferred optout category with a comma:
 //   "offers": paid service offers
 //   "asks": requests for donations or membership signup/renewal to CiviCRM
 //   "releases": major release announcements
 //   "events": announcements of local/national upcoming events
 // $civicrm_setting['domain']['communityMessagesUrl'] = 'https://alert.civicrm.org/alert?prot=1&ver={ver}&uf={uf}&sid={sid}&lang={lang}&co={co}&optout=offers,asks';

if (!defined('CIVICRM_SITE_KEY')) {
  define( 'CIVICRM_SITE_KEY', '40b17bc35a3b2146dba65e576dfc7d74');
}

if (!defined('CIVICRM_CRED_KEYS') ) {
  define( '_CIVICRM_CRED_KEYS', '%%credKeys%%');
  define( 'CIVICRM_CRED_KEYS', _CIVICRM_CRED_KEYS === '%%' . 'credKeys' . '%%' ? '' : _CIVICRM_CRED_KEYS );
  // Some old installers may not set a decent value, and this extra complexity is a failsafe.
  // Feel free to simplify post-install.
}

/**
 * Enable this constant, if you want to send your email through the smarty
 * templating engine(allows you to do conditional and more complex logic)
 *
 */
if (!defined('CIVICRM_MAIL_SMARTY')) {
  define( 'CIVICRM_MAIL_SMARTY', 0 );
}

// if (!defined('CIVICRM_MAIL_LOG')) {
// define( 'CIVICRM_MAIL_LOG', '/var/www/backdrop/tcog2/local/src/files/civicrm/templates_c//mail.log');
// }

//if (!defined('CIVICRM_MAIL_LOG_AND_SEND')) {
//  define( 'CIVICRM_MAIL_LOG_AND_SEND', 1);
//}


if (!defined('CIVICRM_DOMAIN_ID')) {
  define( 'CIVICRM_DOMAIN_ID', 1);
}

// $civicrm_setting['domain']['environment'] = 'Production';


if (!defined('CIVICRM_DB_CACHE_CLASS')) {
  define('CIVICRM_DB_CACHE_CLASS', 'ArrayCache');
}

if (!defined('CIVICRM_DB_CACHE_HOST')) {
  define('CIVICRM_DB_CACHE_HOST', 'localhost');
}

if (!defined('CIVICRM_DB_CACHE_PORT')) {
  if (CIVICRM_DB_CACHE_CLASS === 'Redis') {
    define('CIVICRM_DB_CACHE_PORT', 6379 );
  }
  else {
    define('CIVICRM_DB_CACHE_PORT', 11211);
  }
}

if (!defined('CIVICRM_DB_CACHE_PASSWORD')) {
  define('CIVICRM_DB_CACHE_PASSWORD', '' );
}

if (!defined('CIVICRM_DB_CACHE_TIMEOUT')) {
  define('CIVICRM_DB_CACHE_TIMEOUT', 3600 );
}

if (!defined('CIVICRM_DB_CACHE_PREFIX')) {
  define('CIVICRM_DB_CACHE_PREFIX', '');
}

if (!defined('CIVICRM_PSR16_STRICT')) {
  define('CIVICRM_PSR16_STRICT', FALSE);
}

// define('CIVICRM_LANGUAGE_MAPPING_FR', 'fr_CA');
// define('CIVICRM_LANGUAGE_MAPPING_EN', 'en_CA');
// define('CIVICRM_LANGUAGE_MAPPING_ES', 'es_MX');
// define('CIVICRM_LANGUAGE_MAPPING_PT', 'pt_BR');
// define('CIVICRM_LANGUAGE_MAPPING_ZH', 'zh_TW');
// define('CIVICRM_LANGUAGE_MAPPING_NL', 'nl_BE');

// if (!defined('CIVICRM_GETTEXT_NATIVE')) {
// define('CIVICRM_GETTEXT_NATIVE', 1);
// }

define('CIVICRM_DEADLOCK_RETRIES', 3);

if (CIVICRM_UF === 'UnitTests') {
  if (!defined('CIVICRM_CONTAINER_CACHE')) define('CIVICRM_CONTAINER_CACHE', 'auto');
}

// if (!defined('CIVICRM_LOG_HASH'))  {
//   define('CIVICRM_LOG_HASH', FALSE );
// }

/**
 * The maximum size a log file may be before it's rotated, in bytes.
 * Set to 0 to disable rotation (only recommended if you have an
 * external logrotate configuration).
 */
// if (!defined('CIVICRM_LOG_ROTATESIZE')) {
//   define('CIVICRM_LOG_ROTATESIZE', 0 );
// }

if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' && !defined('CIVICRM_EXCLUDE_DIRS_PATTERN')) {
  define('CIVICRM_EXCLUDE_DIRS_PATTERN', '@/(\.|node_modules|js/|css/|bower_components|packages/|sites/default/files/private)@');
}

/**
 *
 * Do not change anything below this line. Keep as is
 *
 */

$include_path = '.'           . PATH_SEPARATOR .
                $civicrm_root . PATH_SEPARATOR .
                $civicrm_root . DIRECTORY_SEPARATOR . 'packages' . PATH_SEPARATOR .
                get_include_path( );
if ( set_include_path( $include_path ) === false ) {
   echo "Could not set the include path<p>";
   exit( );
}

if (!defined('CIVICRM_CLEANURL')) {
  if (function_exists('variable_get') && variable_get('clean_url', '0') != '0') {
    define('CIVICRM_CLEANURL', 1 );
  }
  elseif ( function_exists('config_get') && config_get('system.core', 'clean_url') != 0) {
    define('CIVICRM_CLEANURL', 1 );
  }
  elseif( function_exists('get_option') && get_option('permalink_structure') != '' ) {
    define('CIVICRM_CLEANURL', 1 );
  }
  else {
    define('CIVICRM_CLEANURL', 0);
  }
}

// force PHP to auto-detect Mac line endings
ini_set('auto_detect_line_endings', '1');

// make sure the memory_limit is at least 64 MB
$memLimitString = trim(ini_get('memory_limit'));
$memLimitUnit   = strtolower(substr($memLimitString, -1));
$memLimit       = (int) $memLimitString;
switch ($memLimitUnit) {
    case 'g': $memLimit *= 1024;
    case 'm': $memLimit *= 1024;
    case 'k': $memLimit *= 1024;
}
if ($memLimit >= 0 and $memLimit < 134217728) {
    ini_set('memory_limit', '128M');
}

require_once 'CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();

 

@laryn - Rajib is a colleague of mine and we are working together on this. We used the instructions here:
https://docs.civicrm.org/sysadmin/en/latest/integration/backdrop/views/

We also tried the link you shared. None of that is helping. 

See screenshot and note our Backdrop database = tcog2 and CiviCRM database should be = tcog2_civicrm

Does the error message suggest that it's not looking in the right database. 

We have copied all the database prefixes into settings.php AND made the modification to the credentials. 

$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => 'tcog2',
  'username' => 'tcog',
  'password' => 'fake1234',
  'host' => 'localhost',
);

@rajpaul03 @stpaultim,

Can you post the first few lines of the CiviCRM Views integration code that you pasted at the bottom of settings.php?

$database_prefix = array(
  'default' => '',
  'civicrm_acl'                              => '`tcog2_civicrm`.',
  'civicrm_acl_cache'                        => '`tcog2_civicrm`.',

.....
  'civicrm_view_case_activity_recent'        => '`tcog2_civicrm`.',
  'civicrm_view_case_activity_upcoming'      => '`tcog2_civicrm`.',
  'civicrm_website'                          => '`tcog2_civicrm`.',
  'civicrm_word_replacement'                 => '`tcog2_civicrm`.',
  'civicrm_worldregion'                      => '`tcog2_civicrm`.',
);

This is the start and end of the block of table prefix's that we copied into settings.php. 

I removed the backticks first and that did not solve the problem. I then changed

"$database_prefix = array("

to

" $databases['default']['default']['prefix']= array(".

After the second suggestion, it worked. 

I then tried to restore the backticks, just to be clear about which suggestion was the solution and with the backticks, it did not work. It would appear that both suggestions were required for us to get this working.