コード例 #1
0
function CalculateAllDatabaseSize()
{
    global $zdbh;
    include 'cnf/db.php';
    $z_db_user = $user;
    $z_db_pass = $pass;
    $mysqlsql = $zdbh->query("SELECT my_id_pk, my_name_vc FROM x_mysql_databases WHERE my_deleted_ts IS NULL");
    while ($database = $mysqlsql->fetch()) {
        $currentdb = new db_driver("mysql:host={$host};dbname=" . $database['my_name_vc'] . "", $z_db_user, $z_db_pass);
        $currentdb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $dbsize = $currentdb->query("SHOW TABLE STATUS");
        $dbgetsize = 0;
        while ($row = $dbsize->fetch()) {
            $dbgetsize = $dbgetsize + ($row['Data_length'] + $row['Index_length']);
        }
        //$zdbh->query("UPDATE x_mysql_databases SET my_usedspace_bi = '" . $dbgetsize . "' WHERE my_id_pk =" . $database['my_id_pk'] . "");
        $numrows = $zdbh->prepare("UPDATE x_mysql_databases SET my_usedspace_bi = :dbgetsize WHERE my_id_pk =:my_id_pk");
        $numrows->bindParam(':dbgetsize', $dbgetsize);
        $numrows->bindParam(':my_id_pk', $database['my_id_pk']);
        $numrows->execute();
        //echo "Database found: " . $database['my_name_vc'] . " - " . $dbgetsize . " \n";
    }
}
コード例 #2
0
ファイル: dbc.inc.php プロジェクト: bbspike/sentora-core
 * @copyright 2014-2015 Sentora Project (http://www.sentora.org/) 
 * Sentora is a GPL fork of the ZPanel Project whose original header follows:
 *
 * Initiates the database driver object and debug object and registers the $zdhb and $zlo globals for the framework.
 * @package zpanelx
 * @subpackage core
 * @author Bobby Allen (ballen@bobbyallen.me)
 * @copyright ZPanel Project (http://www.zpanelcp.com/)
 * @link http://www.zpanelcp.com/
 * @license GPL (http://www.gnu.org/licenses/gpl.html)
 */
/**
 * @global debug_logger $zlo
 */
global $zlo;
/**
 * @global db_driver $zdbh
 */
global $zdbh;
$zlo = new debug_logger();
try {
    $zdbh = new db_driver("mysql:host={$host};dbname={$dbname}", $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
    $zdbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    $zlo->method = "text";
    $zlo->logcode = "0100";
    $zlo->detail = "Unable to connect or authenticate against the database supplied!";
    $zlo->mextra = $e;
    $error_html = "<style type=\"text/css\"><!--\n            .dbwarning {\n                    font-family: Verdana, Geneva, sans-serif;\n                    font-size: 14px;\n                    color: #C00;\n                    background-color: #FCC;\n                    padding: 30px;\n                    border: 1px solid #C00;\n            }\n            p {\n                    font-size: 12px;\n                    color: #666;\n            }\n            </style>\n            <div class=\"dbwarning\"><strong>Critical Error:</strong> [0100] - Unable to connect or authenticate to the Sentora database (<em>{$dbname}</em>).<p>We advice that you contact the server administrator to ensure that the database server is online and that the correct connection parameters are being used.</p></div>";
    die($error_html);
}