// Create new mysqli object $mysqli = new mysqli('localhost', 'user', 'password', 'database'); // Get the size of the database $result = $mysqli->query('SELECT TABLE_SCHEMA AS "Database Name", ROUND(SUM(data_length + index_length)/1024/1024, 2) AS "Size (MB)" FROM information_schema.tables GROUP BY TABLE_SCHEMA;'); // Print the size of the database print_r($result->fetch_all(MYSQLI_ASSOC));
// Create new PDO object $pdo = new PDO('mysql:host=localhost;dbname=database', 'user', 'password'); // Get the size of the database $result = $pdo->query('SELECT TABLE_SCHEMA AS "Database Name", ROUND(SUM(data_length + index_length)/1024/1024, 2) AS "Size (MB)" FROM information_schema.tables GROUP BY TABLE_SCHEMA;'); // Print the size of the database print_r($result->fetchAll(PDO::FETCH_ASSOC));
// Connect to MySQL server $link = mysql_connect('localhost', 'user', 'password'); // Select database mysql_select_db('database'); // Get the size of the database $result = mysql_query('SELECT TABLE_SCHEMA AS "Database Name", ROUND(SUM(data_length + index_length)/1024/1024, 2) AS "Size (MB)" FROM information_schema.tables GROUP BY TABLE_SCHEMA;'); // Print the size of the database print_r(mysql_fetch_all($result, MYSQL_ASSOC)); // Close MySQL server connection mysql_close($link);Package library: mysql (deprecated)