MediaWiki master
MysqlDatabaseCreator.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Installer;
4
7
10 protected function existsInConnection( IDatabase $conn, $database ) {
11 return (bool)$conn->newSelectQueryBuilder()
12 ->select( '1' )
13 ->from( 'information_schema.schemata' )
14 ->where( [ 'schema_name' => $database ] )
15 ->caller( __METHOD__ )
16 ->fetchRow();
17 }
18
20 protected function createInConnection( IDatabase $conn, $database ): Status {
21 $encDatabase = $conn->addIdentifierQuotes( $database );
22 $conn->query( "CREATE DATABASE IF NOT EXISTS $encDatabase", __METHOD__ );
23 return Status::newGood();
24 }
25}
createInConnection(IDatabase $conn, $database)
Create a database on a connection.Status
existsInConnection(IDatabase $conn, $database)
Determine whether a database exists on a connection.bool
Common code for MySQL and PostgreSQL, which are similar due to the fact that databases can be created...
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:44
Interface to a relational database.
Definition IDatabase.php:31
query( $sql, $fname=__METHOD__, $flags=0)
Run an SQL query statement and return the result.
newSelectQueryBuilder()
Create an empty SelectQueryBuilder which can be used to run queries against this connection.