JSchemaChangeitem
Extends \JObjectEach 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/
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)
since |
11.1 |
---|
Arguments
- $properties
mixed
Either 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
since |
11.1 |
---|---|
deprecated |
12.3 Classes should provide their own __toString() implementation. |
Response
string
The 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
boolean
true on success, false otherwise
def
Sets a default value if not alreay assigned
def(string $property, mixed $default = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $default
mixed
The 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
since |
11.1 |
---|---|
see | \JObject::getProperties() |
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
The value of the property.
getError
Get the most recent error message.
getError(integer $i = null, boolean $toString = true) : string
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $i
integer
Option error index.- $toString
boolean
Indicates if JError objects should return their error message.
Response
string
Error message
getErrors
Return all errors, if any.
getErrors() : array
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Response
array
Array of error messages or JErrors.
getInstance
Returns an instance of the correct schemachangeitem for the $db
getInstance(\JDatabase $db, string $file, string $query) : \JSchemaChangeItem
since |
2.5 |
---|
Arguments
- $db
- $file
string
full path name of the sql file- $query
string
text of the sql query (one line of the file)
Response
\JSchemaChangeItem
for the $db driver
getProperties
Returns an associative array of object properties.
getProperties(boolean $public = true) : array
since |
11.1 |
---|---|
see | \JObject::get() |
Arguments
- $public
boolean
If 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
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $value
mixed
The value of the property to set.
Response
mixed
Previous value of the property.
setError
Add an error message.
setError(string $error) : void
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $error
string
Error message.
setProperties
Set the object properties based on a named array/hash.
setProperties(mixed $properties) : boolean
since |
11.1 |
---|---|
see | \JObject::set() |
Arguments
- $properties
mixed
Either an associative array or another object.
Response
boolean
toString
Converts the object to a string (the class name).
toString() : 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.