src/wcmf/lib/util/DBUtil.php
public static function createDatabase($name, $server, $user, $password) {
    $created = false;
    if($name && $server && $user) {
      // setup connection
      $conn =null;
      try {
        $conn = new PDO("mysql:host=$server", $user, $password);
      }
      catch(\Exception $ex) {
      	throw new PersistenceException("Couldn't connect to MySql: ".$ex->getMessage());
      }
      // create database
      $sqlStmt = "CREATE DATABASE IF NOT EXISTS ".$name;
      $result = $conn->query($sqlStmt);
      if ($result) {
        $created = true;
      }
      if (!$created) {
  	    throw new PersistenceException("Couldn't create database: ".$conn->errorInfo());
      }
    }
  }
public static function createDatabase($name, $server, $user, $password) {
    $created = false;
    if($name && $server && $user) {
      // setup connection
      $conn =null;
      try {
        $conn = new PDO("mysql:host=$server", $user, $password);
      }
      catch(\Exception $ex) {
      	throw new PersistenceException("Couldn't connect to MySql: ".$ex->getMessage());
      }
      // create database
      $sqlStmt = "CREATE DATABASE IF NOT EXISTS ".$name;
      $result = $conn->query($sqlStmt);
      if ($result) {
        $created = true;
      }
      if (!$created) {
  	    throw new PersistenceException("Couldn't create database: ".$conn->errorInfo());
      }
    }
  }
public static function createDatabase ( $ name , $ server , $ user , $ password ) { $ created = false ; if ( $ name && $ server && $ user ) { // setup connection $ conn = null ; try { $ conn = new PDO ( "mysql:host=$server" , $ user , $ password ) ; } catch ( \ Exception $ ex ) { throw new PersistenceException ( "Couldn't connect to MySql: " . $ ex -> getMessage ( ) ) ; } // create database $ sqlStmt = "CREATE DATABASE IF NOT EXISTS " . $ name ; $ result = $ conn -> query ( $ sqlStmt ) ; if ( $ result ) { $ created = true ; } if ( ! $ created ) { throw new PersistenceException ( "Couldn't create database: " . $ conn -> errorInfo ( ) ) ; } } }
Crate a database on the server. This works only for MySQL databases.
@param $name The name of the source database
@param $server The name of the database server
@param $user The user name
@param $password The password
Crate a database on the server . This works only for MySQL databases .