Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Protected Attributes | List of all members
database_exporter Class Reference

Base class for database export operations. More...

Inheritance diagram for database_exporter:
database_mover xml_database_exporter file_xml_database_exporter string_xml_database_exporter

Public Member Functions

 __construct (moodle_database $mdb, $check_schema=true)
 Object constructor. More...
 
 begin_database_export ($version, $release, $timestamp, $description)
 Callback function. More...
 
 begin_table_export (xmldb_table $table)
 Callback function. More...
 
 export_database ($description=null)
 Generic method to export the database. More...
 
 export_table_data (xmldb_table $table, $data)
 Callback function. More...
 
 finish_database_export ()
 Callback function. More...
 
 finish_table_export (xmldb_table $table)
 Callback function. More...
 

Protected Attributes

bool $check_schema
 Boolean flag - whether or not to check that XML database schema matches the RDBMS database schema before exporting (used by. More...
 
database_manager $manager
 Database manager of the source database (a. More...
 
moodle_database $mdb
 Connection to the source database (a. More...
 
xmldb_structure $schema
 Source database schema in XMLDB format (a. More...
 

Detailed Description

Base class for database export operations.

This class defines basic callbacks for export operations and implements the

See also
export_database and @export_table methods generic export processing. In general, subclasses will override callback methods to provide specific output and (optionally)
export_database to add functionality. Between a single pair of calls to
begin_database_export and
finish_database_export, multiple non-overlapping pairs of calls may be made to
begin_table_export and
finish_database_export for different tables. Between one pair of calls to
begin_table_export and
finish_database_export multiple calls may be made to
export_table_data for the same table.

Constructor & Destructor Documentation

◆ __construct()

database_exporter::__construct ( moodle_database  $mdb,
  $check_schema = true 
)

Object constructor.

Parameters
moodle_database$mdbConnection to the source database (a
See also
moodle_database object).
Parameters
boolean$check_schema- whether or not to check that XML database schema matches the RDBMS database schema before exporting (used by
See also
export_database).

Member Function Documentation

◆ begin_database_export()

database_exporter::begin_database_export (   $version,
  $release,
  $timestamp,
  $description 
)
abstract

Callback function.

Should be called only once database per export operation, before any other export operations. Subclasses should export basic database information (version and timestamp).

Parameters
float$versionthe version of the system which generating the data
string$releasemoodle release info
string$timestampthe timestamp of the data (in ISO 8601) format.
string$descriptiona user description of the data.
Return values
void

Reimplemented in xml_database_exporter, and database_mover.

◆ begin_table_export()

database_exporter::begin_table_export ( xmldb_table  $table)
abstract

Callback function.

Should be called only once per table export operation, before any other table export operations. Subclasses should export basic database information (name and schema's hash).

Parameters
xmldb_table$table- XMLDB object for the exported table
Return values
void

Reimplemented in xml_database_exporter, and database_mover.

◆ export_database()

database_exporter::export_database (   $description = null)

Generic method to export the database.

It checks the schema (if

See also
$check_schema is true), queries the database and calls appropriate callbacks.
Exceptions
dbtransfer_exceptionif any checking (e.g. database schema) fails
Parameters
string$descriptiona user description of the data.

Reimplemented in string_xml_database_exporter, and file_xml_database_exporter.

◆ export_table_data()

database_exporter::export_table_data ( xmldb_table  $table,
  $data 
)
abstract

Callback function.

Should be called only once per record export operation, only between

See also
begin_table_export and
finish_table_export calls. It will insert table data. Subclasses should export basic record information (data values).
Parameters
xmldb_table$table- XMLDB object of the table from which data was retrieved
object$data- data object (fields and values from record)
Return values
void

Reimplemented in xml_database_exporter, and database_mover.

◆ finish_database_export()

database_exporter::finish_database_export ( )
abstract

Callback function.

Should be called only once database per export operation, after all database export operations.

Reimplemented in xml_database_exporter, and database_mover.

◆ finish_table_export()

database_exporter::finish_table_export ( xmldb_table  $table)
abstract

Callback function.

Should be called only once per table export operation, after all other table export operations.

Parameters
xmldb_table$table- XMLDB object for the exported table

Reimplemented in xml_database_exporter, and database_mover.

Member Data Documentation

◆ $check_schema

bool database_exporter::$check_schema
protected

Boolean flag - whether or not to check that XML database schema matches the RDBMS database schema before exporting (used by.

See also
export_database).

◆ $manager

database_manager database_exporter::$manager
protected

Database manager of the source database (a.

See also
database_manager object).

◆ $mdb

moodle_database database_exporter::$mdb
protected

Connection to the source database (a.

See also
moodle_database object).

◆ $schema

xmldb_structure database_exporter::$schema
protected

Source database schema in XMLDB format (a.

See also
xmldb_structure object).

The documentation for this class was generated from the following file: