php8.5
Home/ Manual/ mysql_xdevapi / session/ Session::createSchema

Session::createSchema

PHP function Edit on GitHub ✎

Create new schema

Description

mysql_xdevapi\Session::createSchema(string $schema_name): mysql_xdevapi\Schema

Creates a new schema.

Parameters

schema_name

Name of the schema to create.

Return Values

A Schema object on success, and emits an exception on failure.

Examples

mysql_xdevapi\Session::createSchema() example

php
<?php
$uri  = 'mysqlx://happyuser:password@127.0.0.1:33060/';
$sess = mysql_xdevapi\getSession($uri);

try {

    if ($schema = $sess->createSchema('fruit')) {
        echo "Info: I created a schema named 'fruit'\n";
    }
    
} catch (Exception $e) {

   echo $e->getMessage();

}
?>

The above example will output something similar to:

output
Info: I created a schema named 'fruit'

Source: reference/mysql_xdevapi/mysql_xdevapi/session/createschema.xml · from the official PHP manual (php/doc-en)