本文整理汇总了PHP中DBConnection::getRootConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnection::getRootConnection方法的具体用法?PHP DBConnection::getRootConnection怎么用?PHP DBConnection::getRootConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection::getRootConnection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
// extract version info from configuration file
$this->config = Config::getInstance();
$this->myLogger = new Logger("autoUpgrade", $this->config->getEnv("debug_level"));
$this->current_version = $this->config->getEnv("version_date");
// connect database with proper permissions
$this->conn = DBConnection::getRootConnection();
if ($this->conn->connect_error) {
throw new Exception("Cannot perform upgrade process: database::dbConnect()");
}
}
示例2: restore
public function restore()
{
// we need root database access to re-create tables
$rconn = DBConnection::getRootConnection();
if ($rconn->connect_error) {
throw new Exception("Cannot perform upgrade process: database::dbConnect()");
}
session_start();
unset($_SESSION['progress']);
session_write_close();
// phase 1: retrieve file from http request
$data = $this->retrieveDBFile();
// phase 2: verify received file
if (strpos(substr($data, 0, 25), "-- AgilityContest") === FALSE) {
throw new Exception("Provided file is not an AgilityContest backup file");
}
// phase 3: delete all tables and structures from database
$this->dropAllTables($rconn);
// phase 4: parse sql file and populate tables into database
$this->readIntoDB($rconn, $data);
// phase 5 final tests
DBConnection::closeConnection($rconn);
return "";
}
示例3: dropTable
public function dropTable()
{
// To create database we need root DB access
$rconn = DBConnection::getRootConnection();
if ($rconn->connect_error) {
throw new Exception("Cannot perform import process: database::dbConnect()");
}
$str = "DROP Table IF EXISTS {$this->tablename};";
$res = $rconn->query($str);
if (!$res) {
$error = $rconn->error;
$str = "ImportExcel(dogs)::dropTable(): Error deleting temporary table: '{$error}'";
$this->myLogger->error($str);
throw new Exception($str);
}
return 0;
}