1

Is there a way to output from the command line the views integration settings as listed in Administer > System Settings > CMS Database Integration? I need this as part of our upgrade script to automatically update settings.php (rewriting a php include file) every time a system upgrade is released.

1

It is possible, you can code it (and because you are a scripter I suppose you are a coder). In CiviCRM, the views settings are generated in the with file https://github.com/civicrm/civicrm-core/blob/master/CRM/Admin/Form/Setting/UF.php

I used this as inspiration to create the following script

<?php
$config = CRM_Core_Config::singleton();
$dsnArray = DB::parseDSN($config->dsn);
$tableNames = CRM_Core_DAO::getTableNames();
$tablePrefixes = '$databases[\'default\'][\'default\'][\'prefix\']= array(';
$tablePrefixes .= "\n  'default' => '$drupal_prefix',"; // add default prefix: the drupal database prefix
$prefix = "";
if ($config->dsn != $config->userFrameworkDSN) {
  $prefix = "`{$dsnArray['database']}`.";
}
foreach ($tableNames as $tableName) {
  $tablePrefixes .= "\n  '" . str_pad($tableName . "'", 41) . " => '{$prefix}',";
}
$tablePrefixes .= "\n);";

echo $tablePrefixes;

Run this script with the CiviCRM cv utility (see https://github.com/civicrm/cv) as follows.

cv scr <scriptname.php>

I tested this on CiviCRM 4.7.27

  • Cool! I will try this and let you know! – ñull Jan 10 '18 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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