class ChangeSet

Contains a set of JSchemaChange objects for a particular instance of Joomla.

Each of these objects contains a DDL query that should have been run against the database when this database was created or updated. This enables the Installation Manager to check that the current database schema is up to date.

Methods

__construct( JDatabaseDriver $db, string $folder = null)

Constructor: builds array of $changeItems by processing the .sql files in a folder.

static  ChangeSet
getInstance( JDatabaseDriver $db, string $folder = null)

Returns a reference to the ChangeSet object, only creating it if it doesn't already exist.

array
check()

Checks the database and returns an array of any errors found.

void
fix()

Runs the update query to apply the change to the database

array
getStatus()

Returns an array of results for this set

string
getSchema()

Gets the current database schema, based on the highest version number.

Details

__construct( JDatabaseDriver $db, string $folder = null)

Constructor: builds array of $changeItems by processing the .sql files in a folder.

The folder for the Joomla core updates is administrator/components/com_admin/sql/updates/<database>.

Parameters

JDatabaseDriver $db The current database object
string $folder The full path to the folder containing the update queries

static ChangeSet getInstance( JDatabaseDriver $db, string $folder = null)

Returns a reference to the ChangeSet object, only creating it if it doesn't already exist.

Parameters

JDatabaseDriver $db The current database object
string $folder The full path to the folder containing the update queries

Return Value

ChangeSet

array check()

Checks the database and returns an array of any errors found.

Note these are not database errors but rather situations where the current schema is not up to date.

Return Value

array Array of errors if any.

void fix()

Runs the update query to apply the change to the database

Return Value

void

array getStatus()

Returns an array of results for this set

Return Value

array associative array of changeitems grouped by unchecked, ok, error, and skipped

string getSchema()

Gets the current database schema, based on the highest version number.

Note that the .sql files are named based on the version and date, so the file name of the last file should match the database schema version in the #__schemas table.

Return Value

string the schema version for the database