Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatible with firebird3.0 #53

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "marquine/php-etl",
"name": "claonilton/php-etl",
"description": "Extract, Transform and Load data using PHP.",
"keywords": ["etl", "extract", "transform", "load", "extraction", "transformation", "seed", "data", "laravel"],
"license": "MIT",
"authors": [
{
"name": "Leonardo Marquine",
"email": "leonardomarquine@gmail.com"
"name": "Claonilton Jr",
"email": "claonilton@vscorp.com.br"
}
],
"require": {
Expand Down
2 changes: 2 additions & 0 deletions src/Database/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ protected function getConnector($driver)
return new Connectors\PostgresConnector;
case 'sqlsrv':
return new Connectors\SqlServerConnector;
case 'firebird':
return new Connectors\FirebirdConnector;
}

throw new InvalidArgumentException("Unsupported driver: $driver");
Expand Down
55 changes: 55 additions & 0 deletions src/Database/Connectors/FirebirdConnector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Marquine\Etl\Database\Connectors;

class FirebirdConnector extends Connector
{
/**
* Connect to a database.
*
* @param array $config
* @return \PDO
*/
public function connect($config)
{
$dsn = $this->getDsn($config);

$connection = $this->createConnection($dsn, $config);


return $connection;


}

/**
* Get the DSN string.
*
* @param array $config
* @return string
*/
public function getDsn($config)
{
extract($config, EXTR_SKIP);

$dsn = [];

if (isset($host) && ! isset($unix_socket)) {
$dsn['host'] = $host;
}

if (isset($port) && ! isset($unix_socket)) {
$dsn['port'] = $port;
}
if (isset($charset) && ! isset($unix_socket)) {
$dsn['charset'] = $charset;
}
if (isset($port) && isset($database) && isset($host) && ! isset($unix_socket)) {
$dsn['dbname'] = "$host/$port:$database";
}

return urldecode('firebird:' . http_build_query($dsn, '', ';'));


}
}
38 changes: 38 additions & 0 deletions src/Transformers/Base64Decode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Marquine\Etl\Transformers;

use Marquine\Etl\Row;

class Base64Decode extends Transformer
{
/**
* Transformer columns.
*
* @var array
*/
protected $columns = [];

/**
* Properties that can be set via the options method.
*
* @var array
*/
protected $availableOptions = [
'columns',
];

/**
* Transform the given row.
*
* @param \Marquine\Etl\Row $row
* @return void
*/
public function transform(Row $row)
{
$row->transform($this->columns, function ($column) {
return base64_decode($column);
});
}
}

40 changes: 40 additions & 0 deletions src/Transformers/Base64Encode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Marquine\Etl\Transformers;

use Marquine\Etl\Row;

class Base64Encode extends Transformer
{
/**
* Transformer columns.
*
* @var array
*/
protected $columns = [];

/**
* Properties that can be set via the options method.
*
* @var array
*/
protected $availableOptions = [
'columns',
];

/**
* Transform the given row.
*
* @param \Marquine\Etl\Row $row
* @return void
*/
public function transform(Row $row)
{
$row->transform($this->columns, function ($column) {
return base64_encode($column);
});
return($row);

}
}

2 changes: 2 additions & 0 deletions src/bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
$container->bind('replace_transformer', Marquine\Etl\Transformers\Replace::class);
$container->bind('trim_transformer', Marquine\Etl\Transformers\Trim::class);
$container->bind('unique_rows_transformer', Marquine\Etl\Transformers\UniqueRows::class);
$container->bind('base64_encode_transformer', Marquine\Etl\Transformers\Base64Encode::class);
$container->bind('base64_decode_transformer', Marquine\Etl\Transformers\Base64Decode::class);

// Loaders
$container->bind('insert_loader', Marquine\Etl\Loaders\Insert::class);
Expand Down