简体   繁体   English

使用现有的MySQL数据库设置Drupal

[英]Setting up Drupal with an existing MySQL db

I have a website which is linked to a MySQL database; 我有一个链接到MySQL数据库的网站; my DB has a table 'users' which is all nicely structured and already integrated with some desktop applications (ie, can't be changed). 我的数据库有一个“用户”表,该表的结构都很好,并且已经与某些桌面应用程序集成在一起(即无法更改)。

I have just set up Drupal with the Webform module and have cloned my registration form over. 我刚刚使用Webform模块设置了Drupal,并克隆了我的注册表单。 The Drupal version stores everything differently internally of course, and my challenge is to get my Drupal webform to save to my existing well-structured database. Drupal版本当然会在内部以不同的方式存储所有内容,而我的挑战是让我的Drupal Web表单保存到我现有的结构良好的数据库中。

There is a hook_webform_component_presave function in my webform.api.php file which I believe does the saving, should I intercept the call here and call my own database? 我的webform.api.php文件中有一个hook_webform_component_presave函数,我相信这样做可以保存,我应该在这里拦截该调用并调用自己的数据库吗?

You can alter form's submit action like this (from your module of course): 您可以这样更改表单的提交动作(当然是在您的模块中):

function your-module-name_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'your-form-id'){
        $form['#submit'][]='save_users';
    }
}

function save_users($form, &$form_state){
 // Do your user saving magic here

}

Actually, this way you are adding your function as extra one. 实际上,这种方式是将您的功能添加为额外的功能。 Default one will also be called (since this way save_users() is added to $form['submit'] array of actions. 默认值也会被调用(因为通过这种方式将save_users()添加到$form['submit']操作数组中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM