Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用于添加新数据库的drupal用户界面_Php_Drupal_Database Connection - Fatal编程技术网

Php 用于添加新数据库的drupal用户界面

Php 用于添加新数据库的drupal用户界面,php,drupal,database-connection,Php,Drupal,Database Connection,我正在与drupal合作,我的想法是创建一个模块,为用户提供一个界面来定义新的数据库参数,因此用户界面将是一些drupal表单,用户必须给出数据库名称、用户名、密码…和submitt。是否可以获取提交的值并将其放入同一模块中的数组中,然后使用新数组连接到数据库并执行一些查询操作 <?php // drupal forms to fill the database parameters // submitt the values // insert the submitted velues

我正在与drupal合作,我的想法是创建一个模块,为用户提供一个界面来定义新的数据库参数,因此用户界面将是一些drupal表单,用户必须给出数据库名称、用户名、密码…和submitt。是否可以获取提交的值并将其放入同一模块中的数组中,然后使用新数组连接到数据库并执行一些查询操作

<?php
// drupal forms to fill the database parameters
// submitt the values
// insert the submitted velues into the following array:
  $other_database = array(
      'database' => databasename,
      'username' => username,
      'password' => psw,
      'host' => host,
      'port' => port,
      'driver' => drv,
      'prefix' => '',
 );
  /
  Database::addConnectionInfo(databasename, 'default', $other_database);
  db_set_active(databasename);

  // execute queries here
  db_set_active(); // without the paramater means set back to the default for the site
  drupal_set_message(t('The queries have been made.'));

查看hook\u菜单和表单api,这是教程页面,

thx但是我已经创建了表单Iam,只是询问是否可以收集用户提交的值来创建新的数据库数组并连接到它?或者数据库初始化应该只在settings.php文件中定义?