PHP code example of phpinnacle / rosetta

1. Go to this page and download the library: Download phpinnacle/rosetta 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/ */

    

phpinnacle / rosetta example snippets


use PDO;
use PHPinnacle\Rosetta\Connections\PdoConnection;
use PHPinnacle\Rosetta\MetadataLoader;
use PHPinnacle\Rosetta\SerializedDataParser;

$pdo = new PDO(
    'pgsql:host=127.0.0.1;port=5432;dbname=infobase',
    'username',
    'password',
    [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION],
);

$connection = new PdoConnection($pdo);
$loader = new MetadataLoader(new SerializedDataParser);

foreach ($loader->load($connection) as $metadata) {
    echo json_encode(
        $metadata,
        JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR,
    );
}

$metadata = $loader->load(
    $connection,
    only: ['_reference259', '_document638'],
    progress: function (int $processed, int $total) {
        printf("%d of %d\n", $processed, $total);
    },
);

$storageMap = $loader->storageMap($connection);
$typeMap = $loader->typeMap($connection);
$total = $loader->count($storageMap);

for ($offset = 0; $offset < $total; $offset += 100) {
    $chunk = $loader->chunk(
        $connection,
        $storageMap,
        $typeMap,
        offset: $offset,
        limit: 100,
    );
}