public function clone_database($main_db = null, $clone_db = null)
    {

        if (empty($this->db)) {
            throw new DatabaseException('Clone or Main database not connected');
        }

        if (empty($main_db) || empty($clone_db)) {
            throw new DatabaseException('clone names havent been set');
        }

        $sql    = "SHOW CREATE DATABASE `$main_db`";
        $result = $this->fetch_assoc($this->query($sql));

        $create_sql = str_replace($main_db, $clone_db, $result['Create Database']);

        if (empty($create_sql)) {
            throw new DatabaseException('Create database statement is empty!');
        }

        return $this->query($create_sql);
    }
public function clone_database($main_db = null, $clone_db = null)
    {

        if (empty($this->db)) {
            throw new DatabaseException('Clone or Main database not connected');
        }

        if (empty($main_db) || empty($clone_db)) {
            throw new DatabaseException('clone names havent been set');
        }

        $sql    = "SHOW CREATE DATABASE `$main_db`";
        $result = $this->fetch_assoc($this->query($sql));

        $create_sql = str_replace($main_db, $clone_db, $result['Create Database']);

        if (empty($create_sql)) {
            throw new DatabaseException('Create database statement is empty!');
        }

        return $this->query($create_sql);
    }
public function clone_database ( $ main_db = null , $ clone_db = null ) { if ( empty ( $ this -> db ) ) { throw new DatabaseException ( 'Clone or Main database not connected' ) ; } if ( empty ( $ main_db ) || empty ( $ clone_db ) ) { throw new DatabaseException ( 'clone names havent been set' ) ; } $ sql = "SHOW CREATE DATABASE `$main_db`" ; $ result = $ this -> fetch_assoc ( $ this -> query ( $ sql ) ) ; $ create_sql = str_replace ( $ main_db , $ clone_db , $ result [ 'Create Database' ] ) ; if ( empty ( $ create_sql ) ) { throw new DatabaseException ( 'Create database statement is empty!' ) ; } return $ this -> query ( $ create_sql ) ; }
clones the specific database

@param $main_db  string
@param $clone_db string

@return bool
@throws DatabaseException
@throws \Exception
clones the specific database