BackupDb
in package
Simple database export to sql
Tags
Table of Contents
Constants
- VERSION = 0.87
Properties
- $maxRows : int
- $db : PDO
- $enableBuffer : bool
- $procedures : bool
- $tables : array<string, bool>
Methods
- __construct() : mixed
- create() : string|void
- Export selected tables to sql format
- getTables() : array<string, bool>
- Get list of tables to export
- setTable() : void
- Add table to export
- setTables() : void
- Set list of tables to export
- disableBuffer() : void
- Disable buffer for mysql to lower memory consumption
- enableBuffer() : void
- Re-enable disabled buffer
- exportData() : void
- Start exporting data from database
- getEscapeRules() : array<int, bool>
- Get which values should be escaped based on table columns
- getProcedures() : string
- Get database functions and procedures
- loadTables() : void
- Load list of tables with selected prefix
- printData() : void
- Export data from table
- useCompression() : string
- Compress content
Constants
VERSION
public
float
VERSION
= 0.87
Properties
$maxRows
public
static int
$maxRows
= 1000
Number of rows in one insert
$db
protected
PDO
$db
$enableBuffer
protected
bool
$enableBuffer
= false
$procedures
protected
bool
$procedures
$tables
protected
array<string, bool>
$tables
= []
Methods
__construct()
public
__construct(PDO $db[, string|null $loadPrefix = '' ][, bool $procedures = true ]) : mixed
Parameters
- $db : PDO
- $loadPrefix : string|null = ''
-
Null for disable table load -> insert tables manually
- $procedures : bool = true
create()
Export selected tables to sql format
public
create([string|null $fileName = null ][, bool $compress = false ]) : string|void
Parameters
- $fileName : string|null = null
-
export as downloadable file or return as string
- $compress : bool = false
-
should be output compressed (gzip)
Return values
string|voidgetTables()
Get list of tables to export
public
getTables() : array<string, bool>
Return values
array<string, bool>setTable()
Add table to export
public
setTable(string $table[, bool $data = true ]) : void
Parameters
- $table : string
-
table name
- $data : bool = true
-
should export table data
setTables()
Set list of tables to export
public
setTables(array<string, bool> $tables) : void
Parameters
- $tables : array<string, bool>
Tags
disableBuffer()
Disable buffer for mysql to lower memory consumption
protected
disableBuffer() : void
enableBuffer()
Re-enable disabled buffer
protected
enableBuffer() : void
exportData()
Start exporting data from database
protected
exportData() : void
getEscapeRules()
Get which values should be escaped based on table columns
protected
getEscapeRules(string $table) : array<int, bool>
Parameters
- $table : string
Return values
array<int, bool>getProcedures()
Get database functions and procedures
protected
getProcedures(string $database) : string
Parameters
- $database : string
Return values
stringloadTables()
Load list of tables with selected prefix
protected
loadTables(string $prefix) : void
Parameters
- $prefix : string
printData()
Export data from table
protected
printData(string $table) : void
Parameters
- $table : string
useCompression()
Compress content
protected
useCompression(string $string) : string
Parameters
- $string : string