Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcDbSchemaHandlerDataTransfer

DatabaseSchema::ezcDbSchemaHandlerDataTransfer

Interface ezcDbSchemaHandlerDataTransfer

Bulk data transfer functionality.

This interface declares methods common for handlers that support bulk data transfers.

Description:

There are two handler participating in bulk data transfer: source and destination. Each of the handlers must implement ezcDbSchemaHandlerDataTransfer interface.

The source handler implements transfer() method. This method transfers all the tables in storage one-by-one.

For each of the tables we transfer data of, the source handler calls setTableBeingTransferred() method on the destination handler.

For each row being transferred, the source handler calls saveRow() method on the destination handler.

Besides, when the transfer starts, we call destination handler's openTransferDestination() method, and when the transfer finishes, we call destination handler's closeTransferDestination() method.

Here is a typical implementation of transfer() method:

  1.  class SomeSchemaHandler
  2.  {
  3.      public function transfer(  $storage, $storageType, $dstHandler )
  4.      {
  5.          $tables = $this->getTablesList();
  6.          foreach ( $tables as $tableName )
  7.          {
  8.              $tableFields = $this->getTableFields( $tableName );
  9.              $dstHandler->setTableBeingTransferred( $tableName, $tableFields );
  10.  
  11.              $tableData = $this->getTableData( $tableName );
  12.              foreach ( $tableData as $row )
  13.                  $dstHandler->saveRow( $row );
  14.          }
  15.      }
  16.  }

The destination handler should implement the following methods:

  • openTransferDestination()
  • setTableBeingTransferred()
  • saveRow()
  • closeTransferDestination()
If you want your handler to be able to act both as source and destination for bulk data transfers, then you should implement all the interface's methods in the handler.

Source for this file: /DatabaseSchema/src/handlers/data_transfer.php

Method Summary

public void closeTransferDestination( )
Tell destination handler that there is no more data to transfer. [destination]
public void openTransferDestination( $storage , $storageType )
Prepare destination handler for transfer [destination].
public void saveRow( $row )
Save given row. [destination]
public void setTableBeingTransferred( $tableName , [ $tableFields = null] )
Start to transfer data of the next table. [destination]
public void transfer( $storage , $storageType , $dstHandler )
Actually transfer data [source].

Methods

closeTransferDestination

void closeTransferDestination( )

Tell destination handler that there is no more data to transfer. [destination]

openTransferDestination

void openTransferDestination( $storage , $storageType )

Prepare destination handler for transfer [destination].

Parameters:
Name Type Description
$storage
$storageType

saveRow

void saveRow( $row )

Save given row. [destination]

Parameters:
Name Type Description
$row

setTableBeingTransferred

void setTableBeingTransferred( $tableName , [ $tableFields = null] )

Start to transfer data of the next table. [destination]

Parameters:
Name Type Description
$tableName
$tableFields

transfer

void transfer( $storage , $storageType , $dstHandler )

Actually transfer data [source].

Parameters:
Name Type Description
$storage
$storageType
$dstHandler
Documentation generated by phpDocumentor 1.4.3