PHP Class FOF30\Database\Installer

Mostra file Open project: akeeba/fof Class Usage Examples

Protected Properties

Property Type Description
$allTables Internal cache for table list

Public Methods

Method Description
__construct ( JDatabaseDriver $db, string $directory ) Public constructor
getForcedFile ( ) : string Returns the absolute path to the forced XML schema file
getXmlDirectory ( ) : string Returns the directory where XML schema files are stored
nukeCache ( ) : void Clears the internal table list cache
removeSchema ( ) : void Uninstalls the database schema
setForcedFile ( string $forcedFile ) Sets the absolute path to an XML schema file which will be read no matter what. Set to a blank string to let the Installer class auto-detect your schema file based on your database type.
setXmlDirectory ( string $xmlDirectory ) Sets the directory where XML schema files are stored
updateSchema ( ) : void Creates or updates the database schema

Protected Methods

Method Description
conditionMet ( string $table, SimpleXMLElement $node ) : boolean Checks if a condition is met
findSchemaXml ( ) : null | SimpleXMLElemen\SimpleXMLElement Find an suitable schema XML file for this database type and return the SimpleXMLElement holding its information
openAndVerify ( $fileName ) : false | SimpleXMLElemen\SimpleXMLElement Opens the schema XML file and return the SimpleXMLElement holding its information. If the file doesn't exist, it is not a schema file or it doesn't match our database driver we return boolean false.

Private Methods

Method Description
convertTablesToUtf8mb4 ( array $tablesToConvert ) : void Converts the collation of tables listed in $tablesToConvert to utf8mb4_unicode_ci
convertUtf8QueryToUtf8mb4 ( string $query ) : string Automatically upgrade a CREATE TABLE or ALTER TABLE query from plain utf8 to utf8mb4 (UTF-8 Multibyte).
convertUtf8mb4QueryToUtf8 ( string $query ) : string Automatically downgrade a CREATE TABLE or ALTER TABLE query from utf8mb4 (UTF-8 Multibyte) to plain utf8.
extractTablesToConvert ( string $query, string &$tables ) : void Analyzes a query. If it's a CREATE TABLE query the table is added to the $tables array.
getColumnCollation ( string $tableName, string $columnName ) : string Get the collation of a column. Uses an internal cache for efficiency.
getTableCollation ( string $tableName ) : string Get the collation of a table. Uses an internal cache for efficiency.
hasIndex ( string $tableName, string $indexName ) : boolean Returns true if table $tableName has an index named $indexName or if it's impossible to retrieve index names for the table (not enough privileges, not a MySQL database, .
realGetColumnCollation ( string $tableName, string $columnName ) : string Get the collation of a column. This is the internal method used by getColumnCollation.
realGetTableCollation ( string $tableName ) : string Get the collation of a table. This is the internal method used by getTableCollation.

Method Details

__construct() public method

Public constructor
public __construct ( JDatabaseDriver $db, string $directory )
$db JDatabaseDriver The database driver we're going to use to install the tables
$directory string The directory holding the XML schema update files

conditionMet() protected method

Checks if a condition is met
protected conditionMet ( string $table, SimpleXMLElement $node ) : boolean
$table string The table we're operating on
$node SimpleXMLElement The condition definition node
return boolean

findSchemaXml() protected method

Find an suitable schema XML file for this database type and return the SimpleXMLElement holding its information
protected findSchemaXml ( ) : null | SimpleXMLElemen\SimpleXMLElement
return null | SimpleXMLElemen\SimpleXMLElement Null if no suitable schema XML file is found

getForcedFile() public method

Returns the absolute path to the forced XML schema file
public getForcedFile ( ) : string
return string

getXmlDirectory() public method

Returns the directory where XML schema files are stored
public getXmlDirectory ( ) : string
return string

nukeCache() public method

Clears the internal table list cache
public nukeCache ( ) : void
return void

openAndVerify() protected method

Opens the schema XML file and return the SimpleXMLElement holding its information. If the file doesn't exist, it is not a schema file or it doesn't match our database driver we return boolean false.
protected openAndVerify ( $fileName ) : false | SimpleXMLElemen\SimpleXMLElement
return false | SimpleXMLElemen\SimpleXMLElement False if it's not a suitable XML schema file

removeSchema() public method

Uninstalls the database schema
public removeSchema ( ) : void
return void

setForcedFile() public method

Sets the absolute path to an XML schema file which will be read no matter what. Set to a blank string to let the Installer class auto-detect your schema file based on your database type.
public setForcedFile ( string $forcedFile )
$forcedFile string

setXmlDirectory() public method

Sets the directory where XML schema files are stored
public setXmlDirectory ( string $xmlDirectory )
$xmlDirectory string

updateSchema() public method

Creates or updates the database schema
public updateSchema ( ) : void
return void

Property Details

$allTables protected_oe static_oe property

Internal cache for table list
protected static $allTables