如何使用Drupal发布驻留在外部数据库中的数据? [英] How to publish data residing in an external database using Drupal?

查看:121
本文介绍了如何使用Drupal发布驻留在外部数据库中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Drupal很新,并且得到了一些有关视图的混合信息,所以我想看看有没有人可以让我在正确的路径上。



这是我的情况。我有一个单独的数据库(在同一个Drupal数据库服务器上),有很多数据由另一个团队维护。我们想将这些数据发布到网络上,并且在得到一些建议后,看起来像Drupal的意见是要走的路。



问题是,我不知道在哪里从那里去。我阅读了文档,只是看了Lullabot的观点教程,但是我的数据根本不在字段列中。



我读了一个文档,说我不得不描述我的外部数据库给Drupal,但不知道该怎么做。我在drupal.org(服务等)上找到了几个工具,表示他们可以分析数据库并将结构报告回Drupal,但我无法理解。



基本上我想要的最终结果是两件事。首先是简单地将数据从我的外部数据库显示到Drupal节点上(唯一的抓取是,每个页面都是特定于一个数据库实体,尽管数据格式/显示是标准的,数据本身将随着链接而改变,对于示例,www.example.com/ibm应仅提供我们在ibm上的数据,并且随着公司名称的更改以及显示的数据),稍后我可能希望在数据显示之前对其进行一些计算。



任何人都有任何建议如何做这个或任何教程?



如果有帮助,我使用Drupal 7。



在旁注中,如果不可能要在Drupal中执行此操作,即使是这样,那么最好在PHP中创建它,然后以Drupal的方式将其包装起来呢?我正在辩论这个,因为我认为我知道如何在PHP中做到这一点,它可能会给我更多的控制结果(但我有点懒惰,因为我在想,也许Drupal可以为我做:-)



更新:好的,现在我更困惑了我已经查看了视图,仍然无法将其与我的数据库集成。我已经查看了模式,并提供了一种描述数据库或者使用Drupal进行复制的方式。我不知道我是正确的方向(或正确的方向),因为到目前为止,我正在尝试的一切似乎都是一个死胡同。有人可以建议一个教程吗?还是将他们的经验与之完成?我只想从另一个数据库中显示内容到页面上(当用户选择特定的股票行情时),我可能希望允许用户稍后进行自定义(这就是为什么我认为需要视图)。

解决方案

就连接数据库而言,在settings.php中,您可以添加其他数据库连接,并在代码中使用db_set_active('connection_name')函数切换您的活动数据库连接到该源。构建视图的插件 - 这是一个远远超出单个答案范围的大问题。所有我可以说的是Google,祝你好运,并回覆具体细节:)


I'm very new to Drupal and was getting a bit of mixed information about views so I wanted to see if anyone can set me on the right path.

Here's my situation. I have a separate database (on the same Drupal database server), that has a lot of data that's maintained by another team. We want to publish that data to the web and after getting some suggestions it looks like Drupal views is the way to go.

The problem is, I'm not sure where to go from there. I read the documentation and just watched the views tutorial on Lullabot, but my data isn't in the fields columns at all.

I read one document that said I had to "describe" my external database to Drupal but wasn't sure how to do it. I found a few tools on drupal.org (services, etc..) that said they can analyize my database and report the structure back to Drupal but I can't figure it out.

Basically the end result I want is two things. First is to simply display the data as is from my external database onto a Drupal node (the only catch is, each page is specific to a database entity so although the data format/display is standard, the data itself will change with the links, for exmaple, www.example.com/ibm should only provide our data on ibm and as the company name changes so does the data that's displayed) and later I might want to run some calculations on the data before it shows up.

Anyone have any suggestions of how to do this or any tutorials?

If it helps, I'm using Drupal 7.

On a side note, if it's not possible to do this in Drupal or even if it is, would it be better to create this in PHP and then somehow wrap it in Drupal? I'm debating this because I think I know how to do this in PHP and it might give me more control on the result (but i'm being a bit lazy because I'm thinking maybe Drupal can do it for me :-)

Update: Okay, now I'm even more confused. I have looked into views and still can't get it to integrate with my database. I have looked at schemas, and feeds as a way of either describing the database or getting it to replicate with Drupal. I'm not sure if I'm going the right direction (or what the right direction is) because so far everything I am trying seems to be a dead end. Can someone suggest a tutorial? Or relate their experiences getting this done? I simply want to display content from another database onto a page (when users select a specific stock ticker), I may want to allow users to customize it later(which is why I think views are needed).

解决方案

As far as connecting to the database, in settings.php you can add additional database connections and use the db_set_active('connection_name') function in code to switch your active db connection to that source. Building plugins for views - that's a big subject far beyond the scope of a single answer. All I can say is Google it and good luck, and come back with specifics :)

这篇关于如何使用Drupal发布驻留在外部数据库中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆