Constructor
mr_db_dump
__construct
(string $file, [boolean $mustnotexist = true], [boolean $appendtime = true])
-
string
$file: The full path to creat the SQL dump file, EG: $CFG->dataroot.'/archive/plugin/logs.sql'
-
boolean
$mustnotexist: If the file must not exist beforehand. Prevents overwriting files on accident.
-
boolean
$appendtime: Append the time to the file name, helps with uniqueness and informative. EG: Appends _YYYYMMDDHHMMSS
Run the dump and delete records that get added to the dump
One of the primary entry points. Don't use this method when exporting very very large amounts of rows. It is better to use separate delete SQL to remove the rows.
mr_db_dump
archive
(
mixed $table,
moodle_recordset $rs)
-
mixed
$table: The table name or an instance of mr_db_table
-
moodle_recordset
$rs: The recordset to iterate over and add to the dump file
Cleanup!
Can delete the zip file and the SQL file
mr_db_dump
clean
([
boolean $deletezip =
true], [
boolean $deletesql =
true], [
boolean $deleteifempty =
true])
-
boolean
$deletezip: Delete the zip file
-
boolean
$deletesql: Delete the SQL file
-
boolean
$deleteifempty: Force the deletion of both files if they are empty
Actually runs the dump and optionally the archive
-
string|mr_db_table
$table: The table name or an instance of mr_db_table
-
moodle_recordset
$rs: The recordset to iterate over and add to the dump file
-
bool
$archive: If true, then records dumped will also be deleted
Get the number of rows dumped
int
get_rows_dumped
()
Get the zip file path (may not exist!)
string
get_zip_file
()
Run the dump
One of the primary entry points.
mr_db_dump
run
(
mixed $table,
moodle_recordset $rs)
-
mixed
$table: The table name or an instance of mr_db_table
-
moodle_recordset
$rs: The recordset to iterate over and add to the dump file
Validates the file path
Validation steps:
- The path must be set.
- The file extension must be 'sql'
- The file's directory must exist, but this will try to make it first.
- The file and directory must be writable.
Zip the SQL file
string
zip
()