PHP code example of malukenho / migratedb

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

    

malukenho / migratedb example snippets



/**
 * @Configurations(
 *     from_table="user",
 *     to_table="member",
 *     complement="WHERE status = '1'",
 *     type="select"
 * )
 */
class User implements EnumTablesRelation
{
	const user_id = 'id';
	const user_name = 'name'
	const user_pass = 'passwd';
}


/**
 * @Configurations(
 *     from_table="user",
 *     to_table="member"
 * )
 */
class InsertUser implements EnumTablesRelation
{
	const IDENTIFY = 'user_id';
	const USERNAME = 'user_name'
	const PASSWORD = 'user_pass';
}


$loader = DO('...');
$mySql2 = new PDO('...');

$router = new MigrateDB(new User);
 
$result = $router->setConnection($mySql, $mySql2)
    ->MapperDatas('1');
 
$router->replyTo(new InsertUser)
    ->with($result);


$routerClient = new MigrateDB(new ClientData);

$routerClient->registerFilter(new ClientFilter)
    ->replyTo(new ClientDataReply)
    ->with(
        $routerClient->setConnection(
            $mySqlConnection, 
            $fireBirdConnection
        )->MapperDatas(
            rand(0, 9)
        )
    );


/**
 * @Configurations(
 *     from_table="UserList",
 *     to_table="NewUserList",
 *     complement="WHERE UserList.iduser = $1",
 *     type="join"
 * )
 */
class UserRelation implements EnumTablesRelation
{
	const user_id = 'userid';
	const user_name = 'name.user_detail ON id = 1';
	const user_pass = 'passwd';
}


/**
 * @Configurations(
 *     from_table="UserList",
 *     to_table="NewUserList",
 *     complement="WHERE iduser = $1",
 *     type="as"
 * )
 */
class UserRelation implements EnumTablesRelation
{
	const user_id = 'userid';
	const user_name = 'name';
	const user_pass = 'passwd';
}