Method | Description | |
---|---|---|
__construct ( ) | ||
addColumn ( string $table, string $columnName, string $columnType, string | null $placeColumnAfter = null ) : |
Adds a new database table column to an existing table. | |
addColumns ( string $table, array $columns, string | null $placeColumnAfter = null ) : |
Adds multiple new database table columns to an existing table at once. | |
addIndex ( string $table, string[] | string $columnNames, string $indexName = '' ) : |
Adds an index to an existing database table. | |
addPrimaryKey ( string $table, string[] | string $columnNames ) : |
Adds a primary key to an existing database table. | |
addUniqueKey ( string $table, string[] | string $columnNames, string $indexName = '' ) : |
Adds a unique key to an existing database table. | |
batchInsert ( string $table, string[] $columnNames, array $values, boolean $throwException = false, string $charset = 'utf8' ) : |
Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs, as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs. | |
boundSql ( string $sql, array $bind, integer | int[] $errorCodesToIgnore = [] ) : |
Performs a custom SQL query that uses bound parameters during the update. | |
changeColumn ( string $table, string $oldColumnName, string $newColumnName, string $columnType ) : |
Changes the column name and column type of an existing database table column. | |
changeColumnType ( string $table, string $columnName, string $columnType ) : |
Changes the type of an existing database table column. | |
changeColumnTypes ( string $table, array $columns ) : |
Changes the type of multiple existing database table columns at the same time. | |
createTable ( string $table, array $columnNames, string | string[] $primaryKey = [] ) : |
Creates a new database table. | |
dropColumn ( string $table, string $columnName ) : |
Drops an existing database table column. | |
dropIndex ( string $table, string $indexName ) : |
Drops an existing index from a database table. | |
dropTable ( string $table ) : |
Drops an existing database table. | |
insert ( string $table, array $columnValuePairs ) : |
Inserts a new record / row into an existing database table. | |
sql ( string $sql, integer | int[] $errorCodesToIgnore = [] ) : |
Performs a custom SQL query during the update. |
Method | Description | |
---|---|---|
prefixTable ( $table ) |
public addColumn ( string $table, string $columnName, string $columnType, string | null $placeColumnAfter = null ) : |
||
$table | string | Unprefixed database table name, eg 'log_visit'. |
$columnName | string | The name of the column that shall be added, eg 'my_column_name'. |
$columnType | string | The column type it should have, eg 'VARCHAR(200) NOT NULL'. |
$placeColumnAfter | string | null | If specified, the added column will be added after this specified column name. If you specify a column be sure it actually exists and can be added after this column. |
return |
public addColumns ( string $table, array $columns, string | null $placeColumnAfter = null ) : |
||
$table | string | Unprefixed database table name, eg 'log_visit'. |
$columns | array | An array of column name to column type pairs, eg array('my_column_name' => 'VARCHAR(200) NOT NULL', 'column2' => '...') |
$placeColumnAfter | string | null | If specified, the first added column will be added after this specified column name. All following columns will be added after the previous specified in $columns. If you specify a column be sure it actually exists and can be added after this column. |
return |
public addIndex ( string $table, string[] | string $columnNames, string $indexName = '' ) : |
||
$table | string | Unprefixed database table name, eg 'log_visit'. |
$columnNames | string[] | string | Either one or multiple column names, eg array('column_name_1', 'column_name_2'). A column name can be appended by a number bracket eg "column_name_1(10)". |
$indexName | string | If specified, the given index name will be used instead of the automatically generated one. |
return |
public addPrimaryKey ( string $table, string[] | string $columnNames ) : |
||
$table | string | Unprefixed database table name, eg 'log_visit'. |
$columnNames | string[] | string | Either one or multiple column names, eg array('column_name_1', 'column_name_2') |
return |
public addUniqueKey ( string $table, string[] | string $columnNames, string $indexName = '' ) : |
||
$table | string | Unprefixed database table name, eg 'log_visit'. |
$columnNames | string[] | string | Either one or multiple column names, eg array('column_name_1', 'column_name_2'). A column name can be appended by a number bracket eg "column_name_1(10)". |
$indexName | string | If specified, the given unique key name will be used instead of the automatically generated one. |
return |
public batchInsert ( string $table, string[] $columnNames, array $values, boolean $throwException = false, string $charset = 'utf8' ) : |
||
$table | string | Unprefixed database table name, eg 'log_visit'. |
$columnNames | string[] | An array of unquoted column names, eg array('column_name1', 'column_name_2') |
$values | array | An array of data to be inserted, eg array(array('row1column1', 'row1column2'),array('row2column1', 'row2column2')) |
$throwException | boolean | Whether to throw an exception that was caught while trying LOAD DATA INFILE, or not. |
$charset | string | The charset to use, defaults to utf8 |
return |
public boundSql ( string $sql, array $bind, integer | int[] $errorCodesToIgnore = [] ) : |
||
$sql | string | The SQL query that should be executed. Make sure to prefix a table name via {@link Piwik\Commin::prefixTable()}. |
$bind | array | An array of values that need to be replaced with the question marks in the SQL query. |
$errorCodesToIgnore | integer | int[] | Any given MySQL server error code will be ignored. For a list of all possible error codes have a look at {@link \Piwik\Updater\Migration\Db}. If no error should be ignored use `false`. |
return |
public changeColumn ( string $table, string $oldColumnName, string $newColumnName, string $columnType ) : |
||
$table | string | Unprefixed database table name, eg 'log_visit'. |
$oldColumnName | string | The current name of the column that shall be renamed/changed, eg 'column_name'. |
$newColumnName | string | The new name of the column, eg 'new_column_name'. |
$columnType | string | The updated type the new column should have, eg 'VARCHAR(200) NOT NULL'. |
return |
public changeColumnType ( string $table, string $columnName, string $columnType ) : |
||
$table | string | Unprefixed database table name, eg 'log_visit'. |
$columnName | string | The name of the column that shall be changed, eg 'my_column_name'. |
$columnType | string | The updated type the column should have, eg 'VARCHAR(200) NOT NULL'. |
return |
public changeColumnTypes ( string $table, array $columns ) : |
||
$table | string | Unprefixed database table name, eg 'log_visit'. |
$columns | array | An array of column name to column type pairs, eg array('my_column_name' => 'VARCHAR(200) NOT NULL', 'column2' => '...') |
return |
public createTable ( string $table, array $columnNames, string | string[] $primaryKey = [] ) : |
||
$table | string | Unprefixed database table name, eg 'log_visit'. |
$columnNames | array | An array of column names and their type they should use. For example: array('column_name_1' => 'VARCHAR(200) NOT NULL', 'column_name_2' => 'INT(10) DEFAULT 0') |
$primaryKey | string | string[] | Optional. One or multiple columns that shall define the primary key. |
return |
public dropColumn ( string $table, string $columnName ) : |
||
$table | string | Unprefixed database table name, eg 'log_visit'. |
$columnName | string | The name of the column that shall be dropped, eg 'my_column_name'. |
return |
public sql ( string $sql, integer | int[] $errorCodesToIgnore = [] ) : |
||
$sql | string | The SQL query that should be executed. Make sure to prefix a table name via {@link Piwik\Commin::prefixTable()}. |
$errorCodesToIgnore | integer | int[] | Any given MySQL server error code will be ignored. For a list of all possible error codes have a look at {@link \Piwik\Updater\Migration\Db}. If no error should be ignored use an empty array or `false`. |
return |