Back to Joomla project (class list)

Class ChangeItem - list of methods

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/`. 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 updating 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.

Direct known subclasses

Package: Joomla\CMS\Schema
Copyright: (C) 2011 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/Schema/ChangeItem.php
Project: Joomla

Method Summary

public
(mixed $db, mixed $file, mixed $query)

Constructor: builds check query and message from $updateQuery
Parameters
  • \Joomla\Database\DatabaseDriver $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)
Since
  • 2.5
Show source code of this method: __construct Source Code

public static \Joomla\CMS\Schema\ChangeItem
(mixed $db, mixed $file, mixed $query)

Returns a reference to the ChangeItem object.
Parameters
  • \Joomla\Database\DatabaseDriver $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)
Returns
  • \Joomla\CMS\Schema\ChangeItem instance based on the database driver
Since
  • 2.5
-
  • \RuntimeException if class for database driver not found
Show source code of this method: getInstance Source Code

protected void
()

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.
Returns
  • void
Since
  • 2.5
Show source code of this method: buildCheckQuery Source Code

public int
()

Runs the check query and checks that 1 row is returned
Returns
  • int 1 if success, -1 if skipped, -2 if check failed
Since
  • 2.5
Show source code of this method: check Source Code

public void
()

Runs the update query to apply the change to the database
Returns
  • void
Since
  • 2.5
Show source code of this method: fix Source Code

Properties Summary

public string
$file
Update file: full path file name where query was found
Since
  • 2.5
public string
$updateQuery
Update query: query used to change the db schema (one line from the file)
Since
  • 2.5
public string
$checkQuery
Check query: query used to check the db schema
Since
  • 2.5
public string
$checkQueryExpected
Check query result: expected result of check query if database is up to date
Since
  • 2.5
public \Joomla\Database\DatabaseDriver
$db
DatabaseDriver object
Since
  • 2.5
public string
$queryType
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
public array
$msgElements
Array with values for use in a Text::sprintf statement indicating what was checked
Since
  • 2.5
public int
$checkStatus
Checked status
Since
  • 2.5
public int
$rerunStatus
Rerun status
Since
  • 2.5

Tags Summary

Since
2.5