MediaWiki master
PostgresDatabaseCreator.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->selectField( '"pg_catalog"."pg_database"', '1',
11 [ 'datname' => $database ], __METHOD__ );
12 }
13
14 protected function createInConnection( IDatabase $conn, $database ): Status {
15 $safedb = $conn->addIdentifierQuotes( $database );
16 $conn->query( "CREATE DATABASE $safedb", __METHOD__ );
17 return Status::newGood();
18 }
19}
Common code for MySQL and PostgreSQL, which are similar due to the fact that databases can be created...
existsInConnection(IDatabase $conn, $database)
Determine whether a database exists on a connection.
createInConnection(IDatabase $conn, $database)
Create a database on a connection.
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:48
query( $sql, $fname=__METHOD__, $flags=0)
Run an SQL query statement and return the result.
selectField( $tables, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a single field from a single result row.