• 0

PHP - Get size/usage of SQL server?


Question

Does anyone know if there is a way to get the size/usage of a SQL database in PHP? I have a custom site that connects to 3 databases and I was working on a control panel page to show the usage and max capacity of each database but I have been unable to find out how to do this.

Google has shown a few SQL specific ways of getting database size, such as sp_databases, but nothing that works directly with PHP.

My web server is hosted and I do not have direct access to the SQL databases, other than through phpmyadmin. That application shows the usage and capacity of each DB, so surely there is a way I can pull that information for my own app as well?

Any help is greatly appreciated.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

After a bit more digging I was able to find some could that worked out for me. Thanks anyways everyone. :)

mysql_select_db( $dbname );

    $result = mysql_query( ?SHOW TABLE STATUS? );

    $dbsize = 0;



    while( $row = mysql_fetch_array( $result ) ) {  



        $dbsize += $row[ "Data_length" ] + $row[ "Index_length" ];



    }

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.