當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。