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:
- class SomeSchemaHandler
- {
- public function transfer( $storage, $storageType, $dstHandler )
- {
- $tables = $this->getTablesList();
- foreach ( $tables as $tableName )
- {
- $tableFields = $this->getTableFields( $tableName );
- $dstHandler->setTableBeingTransferred( $tableName, $tableFields );
- $tableData = $this->getTableData( $tableName );
- foreach ( $tableData as $row )
- $dstHandler->saveRow( $row );
- }
- }
- }
The destination handler should implement the following methods:
- openTransferDestination()
- setTableBeingTransferred()
- saveRow()
- closeTransferDestination()
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
Tell destination handler that there is no more data to transfer. [destination]
openTransferDestination
Prepare destination handler for transfer [destination].
Parameters:
Name | Type | Description |
---|---|---|
$storage |
||
$storageType |
saveRow
Save given row. [destination]
Parameters:
Name | Type | Description |
---|---|---|
$row |
setTableBeingTransferred
Start to transfer data of the next table. [destination]
Parameters:
Name | Type | Description |
---|---|---|
$tableName |
||
$tableFields |
transfer
Actually transfer data [source].
Parameters:
Name | Type | Description |
---|---|---|
$storage |
||
$storageType |
||
$dstHandler |