Read GDB with PHP

Instructions

Run the following command in your project folder to install the PHP-Client for the RebaseData API using Composer.

composer require rebasedata/php-client "1.*"

Then you can read the GDB file using PHP. The following code sample at first defines the input files. Then it converts the input files so that they are readable. This might take a bit of time, since the operation is executed on the secure RebaseData servers. Finally the database table rows are printed. For more examples about how to use the library, check the README.

<?php

require 'vendor/autoload.php';

use RebaseData\Converter\Converter;
use RebaseData\InputFile\InputFile;

$inputFiles = [new InputFile('example.gdb')];

$converter = new Converter();
$database = $converter->convertToDatabase($inputFiles);
$tables = $database->getTables();

foreach ($tables as $table) {
  echo "Reading table '".$table->getName()."'\n";

  $rows = $table->getRowsIterator();
  foreach ($rows as $row) {
    echo implode(', ', $row)."\n";
  }
}

How does it work?

The RebaseData PHP client library internally uses our API to convert the Firebird GDB file to a standardized format. Then you can read the data using PHP as shown above.

Why use RebaseData?

Terms