当前位置: 首页>>代码示例>>PHP>>正文


PHP Toolbox::createSchema方法代码示例

本文整理汇总了PHP中Toolbox::createSchema方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::createSchema方法的具体用法?PHP Toolbox::createSchema怎么用?PHP Toolbox::createSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Toolbox的用法示例。


在下文中一共展示了Toolbox::createSchema方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: step4

function step4($databasename, $newdatabasename)
{
    $host = $_SESSION['db_access']['host'];
    $user = $_SESSION['db_access']['user'];
    $password = $_SESSION['db_access']['password'];
    //display the form to return to the previous step.
    echo "<h3>" . __('Initialization of the database') . "</h3>";
    function prev_form($host, $user, $password)
    {
        echo "<br><form action='install.php' method='post'>";
        echo "<input type='hidden' name='db_host' value='" . $host . "'>";
        echo "<input type='hidden' name='db_user' value='" . $user . "'>";
        echo " <input type='hidden' name='db_pass' value='" . rawurlencode($password) . "'>";
        echo "<input type='hidden' name='update' value='no'>";
        echo "<input type='hidden' name='install' value='Etape_2'>";
        echo "<p class='submit'><input type='submit' name='submit' class='submit' value='" . __s('Back') . "'></p>";
        Html::closeForm();
    }
    //Display the form to go to the next page
    function next_form()
    {
        echo "<br><form action='install.php' method='post'>";
        echo "<input type='hidden' name='install' value='Etape_4'>";
        echo "<p class='submit'><input type='submit' name='submit' class='submit' value='" . __('Continue') . "'></p>";
        Html::closeForm();
    }
    //Check if the port is in url
    $hostport = explode(":", $host);
    if (count($hostport) < 2) {
        $link = new mysqli($hostport[0], $user, $password);
    } else {
        $link = new mysqli($hostport[0], $user, $password, '', $hostport[1]);
    }
    $databasename = $link->real_escape_string($databasename);
    $newdatabasename = $link->real_escape_string($newdatabasename);
    if (!empty($databasename)) {
        // use db already created
        $DB_selected = $link->select_db($databasename);
        if (!$DB_selected) {
            _e('Impossible to use the database:');
            echo "<br>" . sprintf(__('The server answered: %s'), $link->error);
            prev_form($host, $user, $password);
        } else {
            if (DBConnection::createMainConfig($host, $user, $password, $databasename)) {
                Toolbox::createSchema($_SESSION["glpilanguage"]);
                echo "<p>" . __('OK - database was initialized') . "</p>";
                next_form();
            } else {
                // can't create config_db file
                echo "<p>" . __('Impossible to write the database setup file') . "</p>";
                prev_form($host, $user, $password);
            }
        }
    } else {
        if (!empty($newdatabasename)) {
            // create new db
            // Try to connect
            if ($link->select_db($newdatabasename)) {
                echo "<p>" . __('Database created') . "</p>";
                if (DBConnection::createMainConfig($host, $user, $password, $newdatabasename)) {
                    Toolbox::createSchema($_SESSION["glpilanguage"]);
                    echo "<p>" . __('OK - database was initialized') . "</p>";
                    next_form();
                } else {
                    // can't create config_db file
                    echo "<p>" . __('Impossible to write the database setup file') . "</p>";
                    prev_form($host, $user, $password);
                }
            } else {
                // try to create the DB
                if ($link->query("CREATE DATABASE IF NOT EXISTS `" . $newdatabasename . "`")) {
                    echo "<p>" . __('Database created') . "</p>";
                    if ($link->select_db($newdatabasename) && DBConnection::createMainConfig($host, $user, $password, $newdatabasename)) {
                        Toolbox::createSchema($_SESSION["glpilanguage"]);
                        echo "<p>" . __('OK - database was initialized') . "</p>";
                        next_form();
                    } else {
                        // can't create config_db file
                        echo "<p>" . __('Impossible to write the database setup file') . "</p>";
                        prev_form($host, $user, $password);
                    }
                } else {
                    // can't create database
                    echo __('Error in creating database!');
                    echo "<br>" . sprintf(__('The server answered: %s'), $link->error);
                    prev_form($host, $user, $password);
                }
            }
        } else {
            // no db selected
            echo "<p>" . __("You didn't select a database!") . "</p>";
            //prev_form();
            prev_form($host, $user, $password);
        }
    }
    $link->close();
}
开发者ID:btry,项目名称:glpi,代码行数:97,代码来源:install.php

示例2: die

if (file_exists(GLPI_CONFIG_DIR . '/config_db.php') && !isset($args['force'])) {
    die("Already installed (see --force option)\n");
}
$_SESSION = ['glpilanguage' => isset($args['lang']) ? $args['lang'] : 'en_GB'];
Toolbox::setDebugMode(Session::DEBUG_MODE, 0, 0, 1);
echo "Connect to the DB...\n";
//Check if the port is in url
$hostport = explode(':', $args['host']);
if (count($hostport) < 2) {
    $link = new mysqli($hostport[0], $args['user'], $args['pass']);
} else {
    $link = new mysqli($hostport[0], $args['user'], $args['pass'], '', $hostport[1]);
}
if (!$link || mysqli_connect_error()) {
    die("DB connection failed\n");
}
$args['db'] = $link->real_escape_string($args['db']);
echo "Create the DB...\n";
if (!$link->query("CREATE DATABASE IF NOT EXISTS `" . $args['db'] . "`")) {
    die("Can't create the DB\n");
}
if (!$link->select_db($args['db'])) {
    die("Can't select the DB\n");
}
echo "Save configuration file...\n";
if (!DBConnection::createMainConfig($args['host'], $args['user'], $args['pass'], $args['db'])) {
    die("Can't write configuration file\n");
}
echo "Load default schema...\n";
Toolbox::createSchema($_SESSION['glpilanguage']);
echo "Done\n";
开发者ID:btry,项目名称:glpi,代码行数:31,代码来源:cliinstall.php


注:本文中的Toolbox::createSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。