Esempio n. 1
0
function cs_sql_version($cs_file)
{
    global $cs_db;
    $subtype = empty($cs_db['subtype']) ? 'myisam' : strtolower($cs_db['subtype']);
    $sql_infos = array('data_free' => 0, 'data_size' => 0, 'index_size' => 0, 'tables' => 0, 'names' => array());
    $sql_query = "SHOW TABLE STATUS LIKE '" . cs_sql_escape($cs_db['prefix'] . '_') . "%'";
    if ($sql_data = $cs_db['con']->query($sql_query)) {
        $new_result = $sql_data->fetchAll(PDO::FETCH_ASSOC);
        $sql_data = NULL;
        foreach ($new_result as $row) {
            $sql_infos['data_size'] += $row['Data_length'];
            $sql_infos['index_size'] += $row['Index_length'];
            $sql_infos['data_free'] += $subtype == 'innodb' ? 0 : $row['Data_free'];
            $sql_infos['tables']++;
            $sql_infos['names'][] .= $row['Name'];
        }
    } else {
        $error = $cs_db['con']->errorInfo();
        cs_error_sql($cs_file, 'cs_sql_version', $error[2]);
    }
    cs_log_sql($cs_file, $sql_query);
    $sql_infos['type'] = 'MySQL (pdo_mysql)';
    $sql_infos['subtype'] = empty($cs_db['subtype']) ? 'myisam' : $cs_db['subtype'];
    $sql_infos['host'] = $cs_db['con']->getAttribute(PDO::ATTR_CONNECTION_STATUS);
    $sql_infos['encoding'] = 'PDO encoding';
    $sql_infos['client'] = $cs_db['con']->getAttribute(PDO::ATTR_CLIENT_VERSION);
    $sql_infos['server'] = $cs_db['con']->getAttribute(PDO::ATTR_SERVER_VERSION);
    return $sql_infos;
}
Esempio n. 2
0
function cs_sql_version($cs_file)
{
    global $cs_db;
    $sql_infos = array('data_free' => 0, 'data_size' => 0, 'index_size' => 0, 'tables' => 0, 'names' => array());
    $sql_infos['type'] = 'SQLite 3 (pdo_sqlite)';
    $sql_infos['host'] = 'localhost';
    $sql_infos['encoding'] = 'PDO encoding';
    $sql_infos['client'] = $cs_db['con']->getAttribute(PDO::ATTR_CLIENT_VERSION);
    $sql_infos['client'] = str_replace('undefined', '', $sql_infos['client']);
    $sql_infos['server'] = $cs_db['con']->getAttribute(PDO::ATTR_SERVER_VERSION);
    $sql_infos['server'] = str_replace('undefined', '', $sql_infos['server']);
    $sql_query = 'SELECT COUNT(*) FROM sqlite_master WHERE type = \'table\' AND name LIKE \'' . $cs_db['prefix'] . '_%\'';
    if ($sql_data = $cs_db['con']->query($sql_query, PDO::FETCH_NUM)) {
        $sql_result = $sql_data->fetch();
        $sql_data = NULL;
        $sql_infos['tables'] = $sql_result[0];
        $sql_infos['data_size'] = filesize($cs_db['name']);
    } else {
        $error = $cs_db['con']->errorInfo();
        cs_error_sql($cs_file, 'cs_sql_count', $error[2]);
        $sql_infos['tables'] = 0;
    }
    cs_log_sql($cs_file, $sql_query);
    return $sql_infos;
}
Esempio n. 3
0
function cs_sql_update($cs_file, $sql_table, $sql_cells, $sql_content, $sql_id, $sql_where = 0, $sql_log = 1)
{
    global $cs_db;
    settype($sql_id, 'integer');
    $max = count($sql_cells);
    $set = ' SET ';
    for ($run = 0; $run < $max; $run++) {
        $set .= $sql_cells[$run] . "='" . pg_escape_string((string) $sql_content[$run]);
        if ($run != $max - 1) {
            $set .= "', ";
        }
    }
    $set .= "' ";
    $sql_update = 'UPDATE ' . $cs_db['prefix'] . '_' . $sql_table . $set . ' WHERE ';
    if (empty($sql_where)) {
        $sql_update .= $sql_table . '_id = ' . $sql_id;
    } else {
        $sql_update .= $sql_where;
    }
    pg_query($cs_db['con'], $sql_update) or cs_error_sql($cs_file, 'cs_sql_update', cs_sql_error(0, $sql_update));
    cs_log_sql($cs_file, $sql_update, $sql_log);
}
Esempio n. 4
0
function cs_sql_version($cs_file)
{
    global $cs_db;
    $subtype = empty($cs_db['subtype']) ? 'myisam' : strtolower($cs_db['subtype']);
    $sql_infos = array('data_free' => 0, 'data_size' => 0, 'index_size' => 0, 'tables' => 0, 'names' => array());
    $sql_query = "SHOW TABLE STATUS LIKE '" . cs_sql_escape($cs_db['prefix'] . '_') . "%'";
    $sql_data = mysqli_query($cs_db['con'], $sql_query) or cs_error_sql($cs_file, 'cs_sql_version', cs_sql_error(0, $sql_query));
    while ($row = mysqli_fetch_assoc($sql_data)) {
        $sql_infos['data_size'] += $row['Data_length'];
        $sql_infos['index_size'] += $row['Index_length'];
        $sql_infos['data_free'] += $subtype == 'innodb' ? 0 : $row['Data_free'];
        $sql_infos['tables']++;
        $sql_infos['names'][] .= $row['Name'];
    }
    mysqli_free_result($sql_data);
    cs_log_sql($cs_file, $sql_query);
    $sql_infos['encoding'] = mysqli_character_set_name($cs_db['con']);
    $sql_infos['type'] = 'MySQL (mysqli)';
    $sql_infos['subtype'] = empty($cs_db['subtype']) ? 'myisam' : $cs_db['subtype'];
    $sql_infos['client'] = mysqli_get_client_info();
    $sql_infos['host'] = mysqli_get_host_info($cs_db['con']) or cs_error_sql($cs_file, 'cs_sql_version', cs_sql_error());
    $sql_infos['server'] = mysqli_get_server_info($cs_db['con']) or cs_error_sql($cs_file, 'cs_sql_version', cs_sql_error());
    return $sql_infos;
}
Esempio n. 5
0
function cs_sql_version($cs_file)
{
    global $cs_db;
    $version = $cs_db['con']->version();
    $sql_infos = array('data_free' => 0, 'data_size' => 0, 'index_size' => 0, 'tables' => 0, 'names' => array());
    $sql_infos['type'] = 'SQLite 3 (sqlite3)';
    $sql_infos['host'] = 'localhost';
    $sql_infos['client'] = $version['versionString'];
    $sql_infos['server'] = $version['versionString'];
    $sql_infos['encoding'] = 'default';
    $sql_query = 'SELECT COUNT(*) FROM sqlite_master WHERE type = \'table\' AND name LIKE \'' . $cs_db['prefix'] . '_%\'';
    $sql_query = str_replace('{pre}', $cs_db['prefix'], $sql_query);
    if (!($sql_data = $cs_db['con']->query($sql_query))) {
        cs_error_sql($cs_file, 'cs_sql_count', cs_sql_error(0, $sql_query));
    } else {
        $sql_result = $sql_data->fetcharray(SQLITE3_NUM);
        $sql_infos['tables'] = $sql_result[0];
        $sql_infos['data_size'] = filesize($cs_db['name']);
    }
    cs_log_sql($cs_file, $sql_query);
    return $sql_infos;
}