MediaWiki master
MysqlDatabaseCreator.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Installer;
4
7
9 protected function existsInConnection( IDatabase $conn, $database ) {
10 return (bool)$conn->newSelectQueryBuilder()
11 ->select( '1' )
12 ->from( 'information_schema.schemata' )
13 ->where( [ 'schema_name' => $database ] )
14 ->caller( __METHOD__ )
15 ->fetchRow();
16 }
17
18 protected function createInConnection( IDatabase $conn, $database ): Status {
19 $encDatabase = $conn->addIdentifierQuotes( $database );
20 $conn->query( "CREATE DATABASE IF NOT EXISTS $encDatabase", __METHOD__ );
21 return Status::newGood();
22 }
23}
createInConnection(IDatabase $conn, $database)
Create a database on a connection.
existsInConnection(IDatabase $conn, $database)
Determine whether a database exists on a connection.
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:54
Interface to a relational database.
Definition IDatabase.php:45
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.