Copied!
CloneableInstantiable
Methods
public __construct(string $dsn = '', ?string $user = NULL, ?string $pass = NULL, array $settings = [], array $pdoOptions = [])
 

Constructor of Mysqldump.

  • param string $dsn PDO DSN connection string
  • param string|null $user SQL account username
  • param string|null $pass SQL account password
  • param array $settings SQL database settings
  • param array $pdoOptions PDO configured attributes
  • throws \Exception
public addTypeAdapter(string $adapterClassName) : void
 

Add TypeAdapter

  • throws \Exception
public getAdapter(PDO $conn) : Druidfi\Mysqldump\TypeAdapter\TypeAdapterInterface
public getTableLimit(string $tableName) : string|int|false
 

Returns the LIMIT for the table. Must be numeric to be returned.

public getTableWhere(string $tableName) : string|false
public setInfoHook(callable $callable) : void
 

Set a callable that will be used to report dump information.

public setTableLimits(array $tableLimits) : void
 

Keyed by table name, with the value as the numeric limit: e.g. 'users' => 3000

public setTableWheres(array $tableWheres) : void
 

Keyed by table name, with the value as the conditions: e.g. 'users' => 'date_registered > NOW() - INTERVAL 6 MONTH AND deleted=0'

public setTransformColumnValueHook(callable $callable)
 

Set a callable that will be used to transform column values.

public setTransformTableRowHook(callable $callable) : void
 

Set a callable that will be used to transform table rows.

public start(?string $filename = '') : void
 

Primary function, triggers dumping.

  • param string|null $filename Name of file to write sql dump to
  • throws \Exception
Methods
protected getColumnStmt(string $tableName) : array
 

Build SQL List of all columns on current table which will be used for selecting.

  • param string $tableName Name of table to get columns
  • return array SQL sentence with columns for select
protected tableColumnTypes() : array
 

Get table column types.

Properties
private static string $adapterClass = 'Druidfi\Mysqldump\TypeAdapter\TypeAdapterMysql'
private ?PDO $conn = NULL
private Druidfi\Mysqldump\DatabaseConnector $connector
private Druidfi\Mysqldump\TypeAdapter\TypeAdapterInterface $db
private $infoCallable = NULL
private Druidfi\Mysqldump\DumpSettings $settings
private array $tableColumnTypes = []
private array $tableLimits = []
private array $tableWheres = []
 

Keyed on table name, with the value as the conditions.

e.g. - 'users' => 'date_registered > NOW() - INTERVAL 6 MONTH'

private $transformColumnValueCallable = NULL
private $transformTableRowCallable = NULL
private Druidfi\Mysqldump\DumpWriter $writer
Methods
private connect() : void
 

Connect with PDO using the DatabaseConnector.

  • throws \Exception
private createStandInTable(string $viewName) : string
 

Write a create table statement for the table Stand-In, show create table would return a create algorithm when used on a view.

  • param string $viewName Name of view to export
  • return string create statement
private endListValues(string $tableName, int $count = 0)
 

Table rows extractor, close locks and commits after dump.

  • param string $tableName Name of table to export.
  • param int $count Number of rows inserted.
private getColumnNames(string $tableName) : array
 

Build SQL List of all columns on current table which will be used for inserting.

  • param string $tableName Name of table to get columns
  • return array columns for sql sentence for insert
private getDatabaseStructureEvents() : void
 

Reads event names from database. Fills $this->tables array so they will be dumped later.

private getDatabaseStructureFunctions() : void
 

Reads functions names from database. Fills $this->tables array so they will be dumped later.

private getDatabaseStructureProcedures() : void
 

Reads procedure names from database. Fills $this->tables array so they will be dumped later.

private getDatabaseStructureTables() : void
 

Reads table names from database. Fills $this->tables array so they will be dumped later.

private getDatabaseStructureTriggers() : void
 

Reads trigger names from database. Fills $this->tables array so they will be dumped later.

private getDatabaseStructureViews() : void
 

Reads view names from database. Fills $this->tables array so they will be dumped later.

private getDumpFileFooter() : string
 

Returns footer for dump file.

private getDumpFileHeader() : string
 

Returns header for dump file.

private getEventStructure(string $eventName)
 

Event structure extractor.

  • param string $eventName Name of event to export
  • throws \Exception
private getFunctionStructure(string $functionName)
 

Function structure extractor.

  • param string $functionName Name of function to export
private getInsertType() : string
private getProcedureStructure(string $procedureName)
 

Procedure structure extractor.

  • param string $procedureName Name of procedure to export
private getTableColumnTypes(string $tableName) : array
 

Store column types to create data dumps and for Stand-In tables.

  • param string $tableName Name of table to export
  • return array type column types detailed
private getTableStructure(string $tableName)
 

Table structure extractor.

  • param string $tableName Name of table to export
private getTriggerStructure(string $triggerName)
 

Trigger structure extractor.

  • param string $triggerName Name of trigger to export
private getViewStructureTable(string $viewName)
 

View structure extractor, create table (avoids cyclic references).

  • param string $viewName Name of view to export
private getViewStructureView(string $viewName)
 

View structure extractor, create view.

private iterateEvents() : Generator
private iterateFunctions() : Generator
private iterateProcedures() : Generator
private iterateTables() : Generator
 

Stream table names from the database without storing them in memory.

Applies include-tables if provided, otherwise yields all tables.

private iterateTriggers() : Generator
private iterateViews() : Generator
private listValues(string $tableName)
 

Table rows extractor.

  • param string $tableName Name of table to export
private matches(string $table, array $arr) : bool
 

Compare if $table name matches with a definition inside $arr.

private prepareColumnValues(string $tableName, array $row) : array
 

Prepare values for output.

  • param string $tableName Name of table which contains rows
  • param array $row Associative array of column names and values to be quoted
private prepareListValues(string $tableName)
 

Table rows extractor, append information prior to dump.

  • param string $tableName Name of table to export
private write(string $data) : int
Properties
private static string $adapterClass = 'Druidfi\Mysqldump\TypeAdapter\TypeAdapterMysql'
© 2026 Bruce Wells
Search Namespaces \ Classes
Configuration