RefDB Features: programming

A key feature of RefDB is that it is a snap to use it from scripts or even from Makefiles. This greatly simplifies recurring tasks, like feeding the results of a weekly Pubmed search into your database. The simplest way to do this is to use the command line tools in batch mode. For more ambitious projects there are also modules or libraries which allow to integrate RefDB functionality into your very own programs.

On this page
Perl module
PHP module
Ruby library

Perl Module

General Features

Author: Markus Hoenicka <mhoenicka@users.sourceforge.net>

Download RefDBClient-Client

The Perl client module RefDBClient::Client allows Perl programmers to access the refdbd server from Perl scripts. The client/server dialog is implemented entirely in Perl. That is, you don't need the C clients installed on your system in order to run a Perl script using this module. The module allows an object-oriented approach to all RefDB client commands.

Examples

Creating a Perl script that interacts with refdbd is straightforward and simple. First, you create a new instance of RefDBClient::Client and set the initial communication parameters:

use RefDBClient::Client;

my $client = new RefDBClient::Client;

$client->set_conninfo("127.0.0.1", "9734", "markus", "pass", "refdbtest",
"/home/markus/literature", "/usr/local/share/refdb/css/refdb.css");
      

Now you can call any client command and read the retrieved data, if any, into Perl variables:

my $summary = $client->refdb_listdb("");
my $data = $client->get_data();

print "$data\n";
      

This sixliner prints the available RefDB databases to stdout.

Please follow the instructions in the INSTALL file of the archive to install this module properly on your system.

Note: The RefDB SRU interface is implemented using this Perl module.

PHP Module

General Features

Author: Markus Hoenicka <mhoenicka@users.sourceforge.net>

The RefDB web interface is implemented on top of an object-oriented interface to RefDB, see the file phpweb/include/refdblib.inc.php in the RefDB sources. You can include this file into your own PHP project and use it to access a RefDB server.

Examples

Creating a PHP script that interacts with refdbd is fairly simple. First, you create a new instance of RefDB and set the initial communication parameters:

// Load refdb interface
require_once "includes/refdblib.inc.php";

$refdbc="/usr/local/bin/refdbc";

$my_refdbc = new RefDB($username, $passwd, $database, $pdfroot, $refdbc);
      

Now you can call any client command and read the retrieved data, if any, into PHP arrays:

$databases=$my_refdbc->listdb("");

foreach($databases as $aDatabase) {
  echo "<p>".htmlentities($aDatabase)."</p>";
}
      

This simple example displays the available databases on a web page, one per line.

Ruby library

Former author: Diwaker Gupta <diwaker.lists@gmail.com> Currently unmaintained & up for grabs!

There is a Ruby library which implements the basic functionality of the client/server protocol. It is not yet feature-complete but passes a set of basic tests.

If you are interested in using or improving on the library, please check out the rubylib module from the Subversion repository.