P
P
Pure_noob2016-09-02 16:54:27
Drupal
Pure_noob, 2016-09-02 16:54:27

How to connect another database?

Tried connecting another database via settings.php and here is the result >
Fatal error: Class 'RulesEventHandlerEntityBundle' not found in D:\OpenServer\domains\Test2\sites\all\modules\rules\modules\node.rules.inc on line 147
help :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Victor Pleisun, 2016-09-11
@Pure_noob

In settings.php add a new entry to the standard "default" array, for example it is "database2":

$databases = array (
  'default' => 
  array (
    'default' => 
    array (
      'database' => 'users',
      'username' => 'root',
      'password' => '',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
    'database2' => 
    array (
      'database' => 'database',
      'username' => 'root',
      'password' => '',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

Next, in the query, use adding a third argument with the name of the array key "database2":
$import = db_select('field_data_etc', 't', array('target' => 'database2'))
  ->fields('t', array('field_data_etc_value'))
  ->condition('t.field_data_etc', 'value')
  ->condition('t.field_data_etc2', 'value2')
  ->execute()
  ->fetchAssoc();

A
afi13, 2016-09-02
@afi13

The question is not clear, what does it mean to replace the base?
But based on the error, https://www.drupal.org/project/registry_rebuild will help you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question