Class JSchemaChangeitem

Description

Each object represents one query, which is one line from a DDS SQL query.

This class is used to check the site's database to see if the DDL query has been run. If not, it provides the ability to fix the database by re-running the DDL query. The queries are parsed from the update files in the folder administrator/components/com_admin/sql/updates/<database>. These updates are run automatically if the site was updated using com_installer. However, it is possible that the program files could be updated without udpating the database (for example, if a user just copies the new files over the top of an existing installation).

This is an abstract class. We need to extend it for each database and add a buildCheckQuery() method that creates the query to check that a DDL query has been run.

  • abstract:
  • since: 2.5

Located in /libraries/cms/schema/changeitem.php (line 32)

JObject
   |
   --JSchemaChangeitem
Direct descendents
Class Description
JSchemaChangeitemmysql Checks the database schema against one MySQL DDL query to see if it has been run.
JSchemaChangeitemsqlsrv Checks the database schema against one MySQL DDL query to see if it has been run.
Variable Summary
string $checkQuery
string $db
string $file
array $msgElements
string $queryType
string $updateQuery
Method Summary
static JSchemaChangeItem getInstance (JDatabase $db, string $file, string $query)
JSchemaChangeitem __construct (JDatabase $db, string $file,  $updateQuery, string $query, string $checkQuery)
boolean check ()
void fix ()
Variables
string $checkQuery = null (line 53)

Check query: query used to check the db schema

  • access: public
string $checkQueryExpected = 1 (line 60)

Check query result: expected result of check query if database is up to date

  • access: public
int $checkStatus = 0 (line 97)

Checked status

  • var: 0=not checked, -1=skipped, -2=failed, 1=succeeded
  • access: public
string $db = null (line 67)

JDatabase object

  • access: public
string $file = null (line 39)

Update file: full path file name where query was found

  • access: public
array $msgElements = array() (line 90)

Array with values for use in a JText::sprintf statment indicating what was checked

Tells you what the message should be, based on which elements are defined, as follows: For ADD_TABLE: table For ADD_COLUMN: table, column For CHANGE_COLUMN_TYPE: table, column, type For ADD_INDEX: table, index

  • access: public
string $queryType = null (line 77)

Query type: To be used in building a language key for a message to tell user what was checked / changed Possible values: ADD_TABLE, ADD_COLUMN, CHANGE_COLUMN_TYPE, ADD_INDEX

  • access: public
int $rerunStatus = 0 (line 104)

Rerun status

  • var: 0=not rerun, -1=skipped, -2=failed, 1=succeeded
  • access: public
string $updateQuery = null (line 46)

Update query: query used to change the db schema (one line from the file)

  • access: public

Inherited Variables

Inherited from JObject

JObject::$_errors
Methods
static method getInstance (line 136)

Returns an instance of the correct schemachangeitem for the $db

  • return: for the $db driver
  • since: 2.5
  • access: public
static JSchemaChangeItem getInstance (JDatabase $db, string $file, string $query)
  • JDatabase $db
  • string $file: full path name of the sql file
  • string $query: text of the sql query (one line of the file)
Constructor __construct (line 116)

Constructor: builds check query and message from $updateQuery

  • since: 2.5
  • access: public
JSchemaChangeitem __construct (JDatabase $db, string $file,  $updateQuery, string $query, string $checkQuery)
  • JDatabase $db
  • string $file: full path name of the sql file
  • string $query: text of the sql query (one line of the file)
  • string $checkQuery
  • $updateQuery

Redefinition of:
JObject::__construct()
Class constructor, overridden in descendant classes.
check (line 161)

Runs the check query and checks that 1 row is returned If yes, return true, otherwise return false

  • return: true on success, false otherwise
  • since: 2.5
  • access: public
boolean check ()
fix (line 186)

Runs the update query to apply the change to the database

  • since: 2.5
  • access: public
void fix ()

Inherited Methods

Inherited From JObject

JObject::__construct()
JObject::def()
JObject::get()
JObject::getError()
JObject::getErrors()
JObject::getProperties()
JObject::set()
JObject::setError()
JObject::setProperties()
JObject::toString()
JObject::__toString()

Documentation generated on Mon, 25 Jun 2012 13:52:58 -0500 by phpDocumentor 1.4.4