PHP code example of rebasedata / php-client

1. Go to this page and download the library: Download rebasedata/php-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rebasedata / php-client example snippets


    

    eData\Converter\Converter;

    $converter = new Converter();
    

use RebaseData\InputFile\InputFile;

$inputFile = new InputFile('/tmp/access.accdb');

use RebaseData\InputFile\InputFile;

$inputFile = new InputFile('/tmp/a1b2c3e4', 'access.accdb');

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

$inputFile = new InputFile('/tmp/access.accdb');
$inputFiles = [$inputFile];

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

foreach ($tables as $table) {
    echo "Got table: ".$table->getName()."\n";
}

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

$inputFile = new InputFile('/tmp/backup.bak');
$inputFiles = [$inputFile];

$converter = new Converter();
$database = $converter->convertToDatabase($inputFiles, ['password' => 'value']);
$tables = $database->getTables();

foreach ($tables as $table) {
    echo "Got table: ".$table->getName()."\n";
}

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

$inputFile = new InputFile('/tmp/access.accdb');
$inputFiles = [$inputFile];

$converter = new Converter();
$database = $converter->convertToDatabase($inputFiles);
$table = $database->getTable('cars');

foreach ($table->getColumns() as $column) {
    echo "Got column: ".$column->getName()."\n";
}

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

$inputFile = new InputFile('/tmp/access.accdb');
$inputFiles = [$inputFile];

$converter = new Converter();
$database = $converter->convertToDatabase($inputFiles);
$table = $database->getTable('cars');

foreach ($table->getRowsIterator() as $row) {
    echo "Got row: ";
    foreach ($row as $column => $value) {
        echo "$column = $value ";
    }
    echo "\n";
}

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

$inputFile = new InputFile('/tmp/access.accdb');
$inputFiles = [$inputFile];

$converter = new Converter();
$database = $converter->convertToDatabase($inputFiles);
$table = $database->getTable('cars');

$destinationCsvFilePath = '/tmp/cars.csv';

$table->copyTo($destinationCsvFilePath);

echo "You can find the CSV file in $destinationCsvFilePath\n";

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

$inputFile = new InputFile('/tmp/access.accdb');
$inputFiles = [$inputFile];

$targetDirectory = '/tmp/output/';
if (!file_exists($targetDirectory)) {
    mkdir($targetDirectory);
}

$converter = new Converter();
$converter->convertAndSaveToDirectory($inputFiles, 'mysql', $targetDirectory);

echo "You can find the MySQL script file (data.sql) in the following directory: $targetDirectory\n";

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

$inputFile = new InputFile('/tmp/access.accdb');
$inputFiles = [$inputFile];

$zipFile = '/tmp/output.zip';

$converter = new Converter();
$converter->convertAndSaveToZipFile($inputFiles, 'mysql', $zipFile);

echo "You can find the ZIP archive that contains the MySQL script file (data.sql) here: $zipFile\n";

 use RebaseData\Config\Config;
 
 $config = new Config();
 $config->setWorkingDirectory('/tmp/rebasedata-working-dir');
  
 $converter = new Converter($config);
 

 use RebaseData\Config\Config;
 
 $config = new Config();
 $config->setCacheEnabled(true);
 $config->setCacheDirectory('/tmp/cache/');
 
 $converter = new Converter($config);
 

 use RebaseData\Config\Config;
 use RebaseData\Converter\Converter;
 
 $config = new Config();
 $config->setApiKey('secret value');
 
 $converter = new Converter($config);
 
bash
    php composer.phar