Abstract Class JSchemaChangeitem

Description

Each object represents one query, which is one line from a DDL 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 30)


	
			
Direct descendents
Class Description
 class JSchemaChangeitemMysql Checks the database schema against one MySQL DDL query to see if it has been run.
 class JSchemaChangeitemPostgresql Checks the database schema against one PostgreSQL DDL query to see if it has been run.
 class JSchemaChangeitemSqlsrv Checks the database schema against one SQL Server DDL query to see if it has been run.
Variable Summary
Method Summary
 static JSchemaChangeitem getInstance (JDatabaseDriver $db, string $file, string $query)
 JSchemaChangeitem __construct (JDatabaseDriver $db, string $file, string $query)
 void buildCheckQuery ()
 boolean check ()
 void fix ()
Variables
string $checkQuery = null (line 54)

Check query: query used to check the db schema

  • since: 2.5
  • access: public
string $checkQueryExpected = 1 (line 62)

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

  • since: 2.5
  • access: public
integer $checkStatus = 0 (line 102)

Checked status

  • var: 0=not checked, -1=skipped, -2=failed, 1=succeeded
  • since: 2.5
  • access: public
JDatabaseDriver $db = null (line 70)

JDatabaseDriver object

  • since: 2.5
  • access: public
string $file = null (line 38)

Update file: full path file name where query was found

  • since: 2.5
  • access: public
array $msgElements = array() (line 94)

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

  • since: 2.5
  • access: public
string $queryType = null (line 80)

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

  • since: 2.5
  • access: public
int $rerunStatus = 0 (line 110)

Rerun status

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

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

  • since: 2.5
  • access: public
Methods
static getInstance (line 141)

Returns a reference to the JSchemaChangeitem object.

  • return: instance based on the database driver
  • throws: RuntimeException if class for database driver not found
  • since: 2.5
  • access: public
static JSchemaChangeitem getInstance (JDatabaseDriver $db, string $file, string $query)
  • JDatabaseDriver $db: Database connector object
  • string $file: Full path name of the sql file
  • string $query: Text of the sql query (one line of the file)
Constructor __construct (line 121)

Constructor: builds check query and message from $updateQuery

  • since: 2.5
  • access: public
JSchemaChangeitem __construct (JDatabaseDriver $db, string $file, string $query)
  • JDatabaseDriver $db: Database connector object
  • string $file: Full path name of the sql file
  • string $query: Text of the sql query (one line of the file)
buildCheckQuery (line 183)

Checks a DDL query to see if it is a known type If yes, build a check query to see if the DDL has been run on the database.

If successful, the $msgElements, $queryType, $checkStatus and $checkQuery fields are populated. The $msgElements contains the text to create the user message. The $checkQuery contains the SQL query to check whether the schema change has been run against the current database. The $queryType contains the type of DDL query that was run (for example, CREATE_TABLE, ADD_COLUMN, CHANGE_COLUMN_TYPE, ADD_INDEX). The $checkStatus field is set to zero if the query is created

If not successful, $checkQuery is empty and , and $checkStatus is -1. For example, this will happen if the current line is a non-DDL statement.

  • abstract:
  • since: 2.5
  • access: protected
void buildCheckQuery ()

Redefined in descendants as:
check (line 193)

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 226)

Runs the update query to apply the change to the database

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

Documentation generated on Tue, 19 Nov 2013 14:55:39 +0100 by phpDocumentor 1.4.3