You are here

README.txt in Views Database Connector 8

Same filename and directory in other branches
  1. 7 README.txt
Description
-----------
Views Database Connector is a powerful module that gives Views full access to
external database tables found in the settings for your Drupal installation.
With this module, you can setup a view around any table in any database
configuration. This can be extremely useful to pull external data from a
database to show to your users in a view.


Requirements and Limitations
----------------------------
This module depends on access to the information_schema table when using MySQL
or PostgreSQL. If using SQLite, access to the sqlite_master table is required.
These tables are used to gather information about your tables and their
respective column names and data types. If you cannot accommodate this
requirement, this module will not work. Also, any table names that conflict
with Drupal table names cannot be used, and any conflicting table names among
external databases will also need to be resolved. These restrictions are in
place because of the way that Views has structured the return value of its
hook_views_data() API.


Installation
------------
Upload this module's folder to your server and place it in the
sites/all/modules folder. In order to make use of this module, add extra
databases following the instructions found in the installation's
sites/default/settings.php file. After you've added a database or two, enable
the module. If you later decide to change your database configuration, it is
advisable to clear cache and cycle the module's state between disabled and
enabled.


Utilization
-----------
When you add a new view, you should now be able to pick a new entry in the
"Show" select menu to use as the view type. Each item created by this module
will be prefixed by [VDC]. After you select one of these options and create
your view, the first column in the table will be added as the first field. You
should also be able to add the other columns as fields using the "Add" button.


Relationships?
-------------
Relationships are possible with this module, but you need to do some work:

Create a custom module, which will contain two files:

custom_relationships
- custom_relationships.info.yml
- custom_relationships.views.inc

in custom_relationships.info.yml:

<code>
name: "Custom Relationships"
type: module
description: "Custom relationships for VDC Views."
dependencies:
  - views
  - views_database_connector
package: "Views"
core: 8.x
</code>

in custom_relationships.views.inc, put something like the following code,
tailored to your own situation:

<code>
<?php

/**
 * @param array $data
 */
function custom_relationships_views_data_alter(array &$data) {
  $data['Base_DB_table']['just_put_something_here'] = [
    'title' => t('Relationship Name'),
    'relationship' => [
      'base' => 'Relationship_DB_Table',
      'base field' => 'shared_column_in_each_table',
      'field' => 'shared_column_in_each_table',
      'id' => 'views_database_connector_relationship',
      'label' => t('Label for the Relationship'),
    ],
  ];
}
</code>

File

README.txt
View source
  1. Description
  2. -----------
  3. Views Database Connector is a powerful module that gives Views full access to
  4. external database tables found in the settings for your Drupal installation.
  5. With this module, you can setup a view around any table in any database
  6. configuration. This can be extremely useful to pull external data from a
  7. database to show to your users in a view.
  8. Requirements and Limitations
  9. ----------------------------
  10. This module depends on access to the information_schema table when using MySQL
  11. or PostgreSQL. If using SQLite, access to the sqlite_master table is required.
  12. These tables are used to gather information about your tables and their
  13. respective column names and data types. If you cannot accommodate this
  14. requirement, this module will not work. Also, any table names that conflict
  15. with Drupal table names cannot be used, and any conflicting table names among
  16. external databases will also need to be resolved. These restrictions are in
  17. place because of the way that Views has structured the return value of its
  18. hook_views_data() API.
  19. Installation
  20. ------------
  21. Upload this module's folder to your server and place it in the
  22. sites/all/modules folder. In order to make use of this module, add extra
  23. databases following the instructions found in the installation's
  24. sites/default/settings.php file. After you've added a database or two, enable
  25. the module. If you later decide to change your database configuration, it is
  26. advisable to clear cache and cycle the module's state between disabled and
  27. enabled.
  28. Utilization
  29. -----------
  30. When you add a new view, you should now be able to pick a new entry in the
  31. "Show" select menu to use as the view type. Each item created by this module
  32. will be prefixed by [VDC]. After you select one of these options and create
  33. your view, the first column in the table will be added as the first field. You
  34. should also be able to add the other columns as fields using the "Add" button.
  35. Relationships?
  36. -------------
  37. Relationships are possible with this module, but you need to do some work:
  38. Create a custom module, which will contain two files:
  39. custom_relationships
  40. - custom_relationships.info.yml
  41. - custom_relationships.views.inc
  42. in custom_relationships.info.yml:
  43. name: "Custom Relationships"
  44. type: module
  45. description: "Custom relationships for VDC Views."
  46. dependencies:
  47. - views
  48. - views_database_connector
  49. package: "Views"
  50. core: 8.x
  51. in custom_relationships.views.inc, put something like the following code,
  52. tailored to your own situation:
  53. /**
  54. * @param array $data
  55. */
  56. function custom_relationships_views_data_alter(array &$data) {
  57. $data['Base_DB_table']['just_put_something_here'] = [
  58. 'title' => t('Relationship Name'),
  59. 'relationship' => [
  60. 'base' => 'Relationship_DB_Table',
  61. 'base field' => 'shared_column_in_each_table',
  62. 'field' => 'shared_column_in_each_table',
  63. 'id' => 'views_database_connector_relationship',
  64. 'label' => t('Label for the Relationship'),
  65. ],
  66. ];
  67. }