Moodle  2.2.1
http://www.collinsharper.com
database_importer Class Reference
Inheritance diagram for database_importer:

Public Member Functions

 __construct (moodle_database $mdb, $check_schema=true)
 set_transaction_mode ($mode)
 begin_database_import ($version, $timestamp)
 begin_table_import ($tablename, $schemaHash)
 finish_table_import ($tablename)
 finish_database_import ()
 import_table_data ($tablename, $data)
 import_database ()

Protected Attributes

 $mdb
 $manager
 $schema
 $check_schema
 $transactionmode = 'allinone'
 $transaction

Detailed Description

Base class for database import operations. This class implements basic callbacks for import operations and defines the

See also:
import_database method as a common method for all importers. In general, subclasses will override import_database and call other methods in appropriate moments. Between a single pair of calls to
begin_database_import and
finish_database_import, multiple non-overlapping pairs of calls may be made to
begin_table_import and
finish_database_import for different tables. Between one pair of calls to
begin_table_import and
finish_database_import multiple calls may be made to
import_table_data for the same table. This class can be used directly, if the standard control flow (defined above) is respected.

Definition at line 45 of file database_importer.php.


Constructor & Destructor Documentation

__construct ( moodle_database mdb,
check_schema = true 
)

Object constructor.

Parameters:
moodle_database$mdbConnection to the target database (a
See also:
moodle_database object). Use null to use the current $DB connection.
Parameters:
boolean$check_schema- whether or not to check that XML database schema matches the RDBMS database schema before importing (inside
See also:
begin_database_import).

Definition at line 74 of file database_importer.php.

Here is the call graph for this function:


Member Function Documentation

begin_database_import ( version,
timestamp 
)

Callback function. Should be called only once database per import operation, before any database changes are made. It will check the database schema if

See also:
check_schema is true
Exceptions:
dbtransfer_exceptionif any checking (e.g. database schema, Moodle version) fails
Parameters:
float$versionthe version of the system which generated the data
string$timestampthe timestamp of the data (in ISO 8601) format.
Returns:
void

Definition at line 104 of file database_importer.php.

Here is the caller graph for this function:

begin_table_import ( tablename,
schemaHash 
)

Callback function. Should be called only once per table import operation, before any table changes are made. It will delete all table data.

Exceptions:
dbtransfer_exceptionan unknown table import is attempted
ddl_table_missing_exceptionif the table is missing
Parameters:
string$tablename- the name of the table that will be imported
string$schemaHash- the hash of the xmldb_table schema of the table
Returns:
void

Definition at line 145 of file database_importer.php.

Here is the caller graph for this function:

Callback function. Should be called only once database per import operation, after all database changes are made. It will commit changes.

Returns:
void

Definition at line 187 of file database_importer.php.

Here is the caller graph for this function:

finish_table_import ( tablename)

Callback function. Should be called only once per table import operation, after all table changes are made. It will reset table sequences if any.

Parameters:
string$tablename
Returns:
void

Definition at line 168 of file database_importer.php.

Here is the caller graph for this function:

Common import method

Returns:
void

Reimplemented in file_xml_database_importer, and string_xml_database_importer.

Definition at line 214 of file database_importer.php.

import_table_data ( tablename,
data 
)

Callback function. Should be called only once per record import operation, only between

See also:
begin_table_import and
finish_table_import calls. It will insert table data.
Exceptions:
dml_exceptionif data insert operation failed
Parameters:
string$tablename- the name of the table in which data will be imported
object$data- data object (fields and values will be inserted into table)
Returns:
void

Definition at line 206 of file database_importer.php.

Here is the caller graph for this function:

set_transaction_mode ( mode)

How to use transactions during the import.

Parameters:
string$mode'pertable', 'allinone' or 'none'.

Definition at line 85 of file database_importer.php.


Field Documentation

$check_schema [protected]

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

See also:
begin_database_import).

Definition at line 57 of file database_importer.php.

$manager [protected]

Database manager of the target database (a

See also:
database_manager object).

Definition at line 49 of file database_importer.php.

$mdb [protected]

Connection to the target database (a

See also:
moodle_database object).

Definition at line 47 of file database_importer.php.

$schema [protected]

Target database schema in XMLDB format (a

See also:
xmldb_structure object).

Definition at line 51 of file database_importer.php.

$transaction [protected]

Transaction object

Definition at line 63 of file database_importer.php.

$transactionmode = 'allinone' [protected]

How to use transactions.

Definition at line 61 of file database_importer.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations