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

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

问题描述

我对 Drupal 非常陌生,并且获得了一些关于视图的混合信息,所以我想看看是否有人可以让我走上正确的道路.

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.

这是我的情况.我有一个单独的数据库(在同一个 Drupal 数据库服务器上),它有很多由另一个团队维护的数据.我们想将这些数据发布到网络上,在得到一些建议后,看起来 Drupal 视图是可行的方法.

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.

问题是,我不知道从哪里开始.我阅读了文档,只看了 Lullabot 上的视图教程,但我的数据根本不在字段列中.

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.

我阅读了一份文档,其中说我必须向 Drupal描述"我的外部数据库,但不知道该怎么做.我在 drupal.org 上发现了一些工具(服务等),它们说它们可以分析我的数据库并将结构报告回 Drupal,但我无法弄清楚.

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.

基本上我想要的最终结果是两件事.首先是简单地将我的外部数据库中的数据显示到 Drupal 节点上(唯一的问题是,每个页面都特定于一个数据库实体,因此尽管数据格式/显示是标准的,但数据本身会随着链接而改变,例如,www.example.com/ibm 应该只提供我们在 ibm 上的数据,随着公司名称的变化,显示的数据也会发生变化),稍后我可能想在数据显示之前对数据进行一些计算.

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?

如果有帮助,我正在使用 Drupal 7.

If it helps, I'm using Drupal 7.

附带说明一下,如果在 Drupal 中无法做到这一点,或者即使可以做到,在 PHP 中创建它然后以某种方式将其包装在 Drupal 中会更好吗?我正在辩论这个,因为我想我知道如何在 PHP 中做到这一点,它可能让我对结果有更多的控制(但我有点懒,因为我想也许 Drupal 可以为我做这件事 :-)

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 :-)

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

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).

推荐答案

至于连接数据库,在 settings.php 中你可以添加额外的数据库连接,并在代码中使用 db_set_active('connection_name') 函数来切换你的到该源的活动数据库连接.为视图构建插件 - 这是一个远远超出单一答案范围的大主题.我只能说是谷歌它并祝你好运,然后回来提供细节:)

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天全站免登陆