PHP Class Ifsnop\Mysqldump\Mysqldump

Author: Michael J. Calkins ([email protected])
Author: Diego Torres ([email protected])
Datei anzeigen Open project: clouddueling/mysqldump-php Class Usage Examples

Public Properties

Property Type Description
$dsn string Connection string for PDO
$fileName string Destination filename, defaults to stdout
$pass string Database password
$user string Database username

Public Methods

Method Description
__construct ( string $dsn = '', string $user = '', string $pass = '', array $dumpSettings = [], array $pdoSettings = [] ) Constructor of Mysqldump. Note that in the case of an SQLite database connection, the filename must be in the $db parameter.
__destruct ( ) Destructor of Mysqldump. Unsets dbHandlers and database objects.
array_replace_recursive ( array $array1, array $array2 ) : array Custom array_replace_recursive to be used if PHP < 5.3 Replaces elements from passed arrays into the first array recursively
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
endListValues ( string $tableName ) : null Table rows extractor, close locks and commits after dump
getColumnStmt ( string $tableName ) : string Build SQL List of all columns on current table
prepareListValues ( string $tableName ) : null Table rows extractor, append information prior to dump
start ( string $filename = '' ) : null Main call

Private Methods

Method Description
connect ( ) : null Connect with PDO
escape ( string $tableName, array $row ) : string Escape values with quotes when needed
exportProcedures ( ) : null Exports all the procedures found in database
exportTables ( ) : null Exports all the tables selected from database
exportTriggers ( ) : null Exports all the triggers found in database
exportViews ( ) : null Exports all the views found in database
getDatabaseStructure ( ) : null Reads table and views names from database.
getDumpFileFooter ( ) : string Returns footer for dump file
getDumpFileHeader ( ) : string Returns header for dump file
getProcedureStructure ( string $procedureName ) : null Procedure structure extractor
getTableColumnTypes ( string $tableName ) : array Store column types to create data dumps and for Stand-In tables
getTableStructure ( string $tableName ) : null Table structure extractor
getTriggerStructure ( string $triggerName ) : null Trigger structure extractor
getViewStructureTable ( string $viewName ) : null View structure extractor, create table (avoids cyclic references)
getViewStructureView ( string $viewName ) : null View structure extractor, create view
listValues ( string $tableName ) : null Table rows extractor
matches ( $table, $arr ) : boolean Compare if $table name matches with a definition inside $arr
parseDsn ( string $dsn ) 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

Method Details

__construct() public method

Constructor of Mysqldump. Note that in the case of an SQLite database connection, the filename must be in the $db parameter.
public __construct ( string $dsn = '', string $user = '', string $pass = '', array $dumpSettings = [], array $pdoSettings = [] )
$dsn string PDO DSN connection string
$user string SQL account username
$pass string SQL account password
$dumpSettings array SQL database settings
$pdoSettings array PDO configured attributes

__destruct() public method

Destructor of Mysqldump. Unsets dbHandlers and database objects.
public __destruct ( )

array_replace_recursive() public static method

Custom array_replace_recursive to be used if PHP < 5.3 Replaces elements from passed arrays into the first array recursively
public static array_replace_recursive ( array $array1, array $array2 ) : array
$array1 array The array in which elements are replaced
$array2 array The array from which elements will be extracted
return array Returns an array, or NULL if an error occurs.

createStandInTable() public method

Write a create table statement for the table Stand-In, show create table would return a create algorithm when used on a view
public createStandInTable ( string $viewName ) : string
$viewName string Name of view to export
return string create statement

endListValues() public method

Table rows extractor, close locks and commits after dump
public endListValues ( string $tableName ) : null
$tableName string Name of table to export
return null

getColumnStmt() public method

Build SQL List of all columns on current table
public getColumnStmt ( string $tableName ) : string
$tableName string Name of table to get columns
return string SQL sentence with columns

prepareListValues() public method

Table rows extractor, append information prior to dump
public prepareListValues ( string $tableName ) : null
$tableName string Name of table to export
return null

start() public method

Main call
public start ( string $filename = '' ) : null
$filename string Name of file to write sql dump to
return null

Property Details

$dsn public_oe property

Connection string for PDO
public string $dsn
return string

$fileName public_oe property

Destination filename, defaults to stdout
public string $fileName
return string

$pass public_oe property

Database password
public string $pass
return string

$user public_oe property

Database username
public string $user
return string