PHP Class Piwik\DbHelper

Afficher le fichier Open project: piwik/piwik Class Usage Examples

Méthodes publiques

Méthode 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 méthode

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

createAnonymousUser() public static méthode

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

createDatabase() public static méthode

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

createTable() public static méthode

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 méthode

Create all tables
public static createTables ( )

deleteArchiveTables() public static méthode

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

disconnectDatabase() public static méthode

Disconnect from database
public static disconnectDatabase ( )

dropDatabase() public static méthode

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

getTableColumns() public static méthode

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

getTableCreateSql() public static méthode

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

getTablesCreateSql() public static méthode

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

getTablesInstalled() public static méthode

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

isDatabaseConnectionUTF8() public static méthode

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

isInstalled() public static méthode

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

isValidDbname() public static méthode

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
Résultat boolean

truncateAllTables() public static méthode

Truncate all tables
public static truncateAllTables ( )