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)
 

Add TypeAdapter

  • throws \Exception
public getAdapter() : Druidfi\Mysqldump\TypeAdapter\TypeAdapterInterface
public getTableLimit(string $tableName)
 

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

public getTableWhere(string $tableName)
public setInfoHook(callable $callable)
 

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

public setTableLimits(array $tableLimits)
 

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

public setTableWheres(array $tableWheres)
 

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

public setTransformTableRowHook(callable $callable)
 

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

public start(?string $filename = '')
 

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
private Druidfi\Mysqldump\TypeAdapter\TypeAdapterInterface $db
private string $dbName
private string $dsn
private array $events = []
private array $functions = []
private string $host
private $infoCallable = NULL
private Druidfi\Mysqldump\Compress\CompressInterface $io
private ?string $pass
private array $pdoOptions
private array $procedures = []
private Druidfi\Mysqldump\DumpSettings $settings
private array $tableColumnTypes = []
private array $tableLimits = []
private array $tables = []
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 array $triggers = []
private ?string $user
private array $views = []
Methods
private connect()
 

Connect with PDO.

  • 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 exportEvents()
 

Exports all the events found in database.

  • throws \Exception
private exportFunctions()
 

Exports all the functions found in database.

private exportProcedures()
 

Exports all the procedures found in database.

private exportTables()
 

Exports all the tables selected from database

private exportTriggers()
 

Exports all the triggers found in database.

private exportViews()
 

Exports all the views found in database.

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()
 

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

private getDatabaseStructureFunctions()
 

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

private getDatabaseStructureProcedures()
 

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

private getDatabaseStructureTables()
 

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

private getDatabaseStructureTriggers()
 

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

private getDatabaseStructureViews()
 

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 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 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 parseDsn(string $dsn) : string
 

Parse DSN string and extract dbname value Several examples of a DSN string mysql:host=localhost;dbname=testdb mysql:host=localhost;port=3307;dbname=testdb mysql:unix_socket=/tmp/mysql.sock;dbname=testdb

  • param string $dsn dsn string to parse
  • throws \Exception
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'
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration