Skip to content

About

PHP library that allows linking queries from diferent physical databases using mysql pdo database connections

Resources

Stars

0 stars

Watchers

3 watching

Forks

Latest commit

 

History

33 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pdo-mysql-query-linker

Latest Stable Version Total Downloads License Build Status Code Climate

PHP library that allows linking queries from diferent physical databases using mysql pdo database connections.

What is this thing

I'll explain once I get it done.

Install

To add as a dependency using composer:

composer require antevenio/pdo-mysql-query-linker

Usage example

<?php
$originPdo = new PDO('mysql:host=host1;dbname=kidsshouting', 'myuser', 'mypass');
$targetPdo = new PDO('mysql:host=host2;dbname=kidsshouting', 'myuser', 'mypass');

$linker = (new \PdoMysqlQueryLinker\Linker\Factory())->create()
    ->origin(
        $originPdo, 
        "select * from table_in_origin where column = 'something'"
        )
    ->target(
        $targetPdo, 
        "delete from table_in_destination inner join {origin} using(column)"
        );

// Get a limit clause block based iterator
$iterator = $linker->getIterator(10000);
foreach ($iterator as $row) {
    // do your stuff;
}
$linker->close();

// Get a pdo statement
$stmt = $linker->execute();
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
foreach ($rows as $row) {
    // do your stuff;
}
$linker->close();

// Get just the resolved query to run in destination adapter
$query = $linker->getQuery();
$stmt = $targetPdo->query($query);
$linker->close();

About

PHP library that allows linking queries from diferent physical databases using mysql pdo database connections

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages