PHP Class Piwik\DbHelper

Mostrar archivo Open project: piwik/piwik Class Usage Examples

Public Methods

Method Description
checkDatabaseVersion ( ) Checks the database server version against the required minimum version.
createAnonymousUser ( ) Creates an entry in the User table for the "anonymous" user.
createDatabase ( string | null $dbName = null ) Create database
createTable ( string $nameWithoutPrefix, string $createDefinition ) Creates a new table in the database.
createTables ( ) Create all tables
deleteArchiveTables ( ) Deletes archive tables. For use in tests.
disconnectDatabase ( ) Disconnect from database
dropDatabase ( $dbName = null ) Drop database, used in tests
getTableColumns ( string $tableName ) : array Get list of installed columns in a table
getTableCreateSql ( string $tableName ) : string Get the SQL to create a specific Piwik table
getTablesCreateSql ( ) : array Get the SQL to create Piwik tables
getTablesInstalled ( boolean $forceReload = true ) : array Get list of tables installed
isDatabaseConnectionUTF8 ( ) : boolean Check database connection character set is utf8.
isInstalled ( ) : boolean Returns true if Piwik is installed
isValidDbname ( string $dbname ) : boolean Returns true if the string is a valid database name for MySQL. MySQL allows + in the database names.
truncateAllTables ( ) Truncate all tables

Method Details

checkDatabaseVersion() public static method

Checks the database server version against the required minimum version.
Since: 0.4.4
public static checkDatabaseVersion ( )

createAnonymousUser() public static method

Creates an entry in the User table for the "anonymous" user.
public static createAnonymousUser ( )

createDatabase() public static method

Create database
public static createDatabase ( string | null $dbName = null )
$dbName string | null

createTable() public static method

Example: $tableDefinition = "age INT(11) NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL"; DbHelper::createTable('tablename', $tableDefinition);
public static createTable ( string $nameWithoutPrefix, string $createDefinition )
$nameWithoutPrefix string The name of the table without any piwik prefix.
$createDefinition string The table create definition

createTables() public static method

Create all tables
public static createTables ( )

deleteArchiveTables() public static method

Deletes archive tables. For use in tests.
public static deleteArchiveTables ( )

disconnectDatabase() public static method

Disconnect from database
public static disconnectDatabase ( )

dropDatabase() public static method

Drop database, used in tests
public static dropDatabase ( $dbName = null )

getTableColumns() public static method

Get list of installed columns in a table
public static getTableColumns ( string $tableName ) : array
$tableName string The name of a table.
return array Installed columns indexed by the column name.

getTableCreateSql() public static method

Get the SQL to create a specific Piwik table
public static getTableCreateSql ( string $tableName ) : string
$tableName string Unprefixed table name.
return string SQL

getTablesCreateSql() public static method

Get the SQL to create Piwik tables
public static getTablesCreateSql ( ) : array
return array array of strings containing SQL

getTablesInstalled() public static method

Get list of tables installed
public static getTablesInstalled ( boolean $forceReload = true ) : array
$forceReload boolean Invalidate cache
return array Tables installed

isDatabaseConnectionUTF8() public static method

Check database connection character set is utf8.
public static isDatabaseConnectionUTF8 ( ) : boolean
return boolean True if it is (or doesn't matter); false otherwise

isInstalled() public static method

Returns true if Piwik is installed
Since: 0.6.3
public static isInstalled ( ) : boolean
return boolean True if installed; false otherwise

isValidDbname() public static method

Database names that start with a-Z or 0-9 and contain a-Z, 0-9, underscore(_), dash(-), plus(+), and dot(.) will be accepted. File names beginning with anything but a-Z or 0-9 will be rejected (including .htaccess for example). File names containing anything other than above mentioned will also be rejected (file names with spaces won't be accepted).
public static isValidDbname ( string $dbname ) : boolean
$dbname string
return boolean

truncateAllTables() public static method

Truncate all tables
public static truncateAllTables ( )