JSchemaChangeitem

Extends \JObject

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

abstract

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 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.

package

CMS.Library

subpackage

Schema

since

2.5

Methods

__construct

Class constructor, overridden in descendant classes.

__construct(mixed $properties = null) 
inherited
since

11.1

Arguments

$properties

mixedEither and associative array or another object to set the initial properties of the object.

__toString

Magic method to convert the object to a string gracefully.

__toString() : string
inherited deprecated
since

11.1

deprecated

12.3 Classes should provide their own __toString() implementation.

Response

stringThe classname.

check

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

check() : boolean
since

2.5

Response

booleantrue on success, false otherwise

def

Sets a default value if not alreay assigned

def(string $property, mixed $default = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixed

fix

Runs the update query to apply the change to the database

fix() 
since

2.5

get

Returns a property of the object or the default value if the property is not set.

get(string $property, mixed $default = null) : mixed
inherited
since

11.1

see \JObject::getProperties()

Arguments

$property

stringThe name of the property.

$default

mixedThe default value.

Response

mixedThe value of the property.

getError

Get the most recent error message.

getError(integer $i = null, boolean $toString = true) : string
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$i

integerOption error index.

$toString

booleanIndicates if JError objects should return their error message.

Response

stringError message

getErrors

Return all errors, if any.

getErrors() : array
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Response

arrayArray of error messages or JErrors.

getInstance

Returns an instance of the correct schemachangeitem for the $db

getInstance(\JDatabase $db, string $file, string $query) : \JSchemaChangeItem
static
since

2.5

Arguments

$db

\JDatabase

$file

stringfull path name of the sql file

$query

stringtext of the sql query (one line of the file)

Response

\JSchemaChangeItemfor the $db driver

getProperties

Returns an associative array of object properties.

getProperties(boolean $public = true) : array
inherited
since

11.1

see \JObject::get()

Arguments

$public

booleanIf true, returns only the public properties.

Response

array

set

Modifies a property of the object, creating it if it does not already exist.

set(string $property, mixed $value = null) : mixed
inherited
since

11.1

Arguments

$property

stringThe name of the property.

$value

mixedThe value of the property to set.

Response

mixedPrevious value of the property.

setError

Add an error message.

setError(string $error) : void
inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Arguments

$error

stringError message.

setProperties

Set the object properties based on a named array/hash.

setProperties(mixed $properties) : boolean
inherited
since

11.1

see \JObject::set()

Arguments

$properties

mixedEither an associative array or another object.

Response

boolean

toString

Converts the object to a string (the class name).

toString() : string
inherited deprecated
since

11.1

deprecated

12.1 Use magic method __toString()

see \JObject::__toString()

Response

string

Properties

file

Update file: full path file name where query was found

Type(s)

string

updateQuery

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

Type(s)

string

checkQuery

Check query: query used to check the db schema

Type(s)

string

checkQueryExpected

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

Type(s)

string

db

JDatabase object

Type(s)

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

Type(s)

string

msgElements

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

Type(s)

array

checkStatus

Checked status

Type(s)

integer

rerunStatus

Rerun status

Type(s)

integer

_errors

An array of error messages or Exception objects.

inherited deprecated
since

11.1

see \JError
deprecated

12.3 JError has been deprecated

Type(s)

array