Adapter
2 years ago
Schema
1 year ago
Adapter.php
2 years ago
AdapterInterface.php
2 years ago
BatchInsert.php
2 years ago
Schema.php
1 year ago
SchemaInterface.php
1 year ago
Settings.php
1 year ago
TransactionLevel.php
2 years ago
SchemaInterface.php
132 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Matomo - free/libre analytics platform |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 8 | */ |
| 9 | namespace Piwik\Db; |
| 10 | |
| 11 | /** |
| 12 | * Database schema interface |
| 13 | */ |
| 14 | interface SchemaInterface |
| 15 | { |
| 16 | /** |
| 17 | * Get the SQL to create a specific Matomo table |
| 18 | * |
| 19 | * @param string $tableName |
| 20 | * @return string SQL |
| 21 | */ |
| 22 | public function getTableCreateSql($tableName); |
| 23 | /** |
| 24 | * Get the SQL to create Matomo tables |
| 25 | * |
| 26 | * @return array array of strings containing SQL |
| 27 | */ |
| 28 | public function getTablesCreateSql(); |
| 29 | /** |
| 30 | * Creates a new table in the database. |
| 31 | * |
| 32 | * @param string $nameWithoutPrefix The name of the table without any prefix. |
| 33 | * @param string $createDefinition The table create definition |
| 34 | */ |
| 35 | public function createTable($nameWithoutPrefix, $createDefinition); |
| 36 | /** |
| 37 | * Create database |
| 38 | * |
| 39 | * @param string $dbName Name of the database to create |
| 40 | */ |
| 41 | public function createDatabase($dbName = null); |
| 42 | /** |
| 43 | * Drop database |
| 44 | */ |
| 45 | public function dropDatabase(); |
| 46 | /** |
| 47 | * Create all tables |
| 48 | */ |
| 49 | public function createTables(); |
| 50 | /** |
| 51 | * Creates an entry in the User table for the "anonymous" user. |
| 52 | */ |
| 53 | public function createAnonymousUser(); |
| 54 | /** |
| 55 | * Records the Matomo version a user used when installing this Matomo for the first time |
| 56 | */ |
| 57 | public function recordInstallVersion(); |
| 58 | /** |
| 59 | * Returns which Matomo version was used to install this Matomo for the first time. |
| 60 | */ |
| 61 | public function getInstallVersion(); |
| 62 | /** |
| 63 | * Truncate all tables |
| 64 | */ |
| 65 | public function truncateAllTables(); |
| 66 | /** |
| 67 | * Names of all the prefixed tables in Matomo |
| 68 | * Doesn't use the DB |
| 69 | * |
| 70 | * @return array Table names |
| 71 | */ |
| 72 | public function getTablesNames(); |
| 73 | /** |
| 74 | * Get list of tables installed |
| 75 | * |
| 76 | * @param bool $forceReload Invalidate cache |
| 77 | * @return array installed Tables |
| 78 | */ |
| 79 | public function getTablesInstalled($forceReload = true); |
| 80 | /** |
| 81 | * Get list of installed columns in a table |
| 82 | * |
| 83 | * @param string $tableName The name of a table. |
| 84 | * |
| 85 | * @return array Installed columns indexed by the column name. |
| 86 | */ |
| 87 | public function getTableColumns($tableName); |
| 88 | /** |
| 89 | * Checks whether any table exists |
| 90 | * |
| 91 | * @return bool True if tables exist; false otherwise |
| 92 | */ |
| 93 | public function hasTables(); |
| 94 | /** |
| 95 | * Adds a max execution time query hint into a SELECT query if $limit is bigger than 0 |
| 96 | * (floating values for limit might be rounded to full seconds depending on DB support) |
| 97 | * |
| 98 | * @param string $sql query to add hint to |
| 99 | * @param float $limit time limit in seconds |
| 100 | * @return string |
| 101 | */ |
| 102 | public function addMaxExecutionTimeHintToQuery(string $sql, float $limit) : string; |
| 103 | /** |
| 104 | * Returns if the database supports column updates in table updates. |
| 105 | * Some database engines are performing sanity checks for table updates. Those might include checking if all columns used |
| 106 | * already exist. In such a case queries like this might fail: `ALTER TABLE t ADD COLUMN b, ADD INDEX i (b)` |
| 107 | * |
| 108 | * @return bool |
| 109 | */ |
| 110 | public function supportsComplexColumnUpdates() : bool; |
| 111 | /** |
| 112 | * Returns the default collation for a charset used by this database engine. |
| 113 | * |
| 114 | * @param string $charset |
| 115 | * |
| 116 | * @return string |
| 117 | */ |
| 118 | public function getDefaultCollationForCharset(string $charset) : string; |
| 119 | /** |
| 120 | * Return the default port used by this database engine |
| 121 | * |
| 122 | * @return int |
| 123 | */ |
| 124 | public function getDefaultPort() : int; |
| 125 | /** |
| 126 | * Return the table options to use for a CREATE TABLE statement. |
| 127 | * |
| 128 | * @return string |
| 129 | */ |
| 130 | public function getTableCreateOptions() : string; |
| 131 | } |
| 132 |