How To get DATABASE SIZE |
[eluser]pmsfo[/eluser]
Hi How can i get the database size using the database library from codeigniter ?
[eluser]johnpeace[/eluser]
What do you mean by 'size'? The number of records in each table? The KB file size of the binary files the database stores? The number of tables in the DB? This query might be a good start: Code: SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB"
[eluser]pmsfo[/eluser]
For example i have i database namee "bacula" that as 15 tables, what i what to know is the size of the database, but using the condeigniter library. For mysql i can do this 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" ]; } I what to do is for all databases types postgres, mysql, sqlite, using the codeigniter library.
[eluser]johnpeace[/eluser]
[quote author="pmsfo" date="1297283518"]For example i have i database namee "bacula" that as 15 tables, what i what to know is the size of the database, but using the condeigniter library. For mysql i can do this 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" ]; } I what to do is for all databases types postgres, mysql, sqlite, using the codeigniter library.[/quote] I think you'd have to extend the DB class for that functionality. Alternatively, you could create a helper that has a function to return database filesize for a given DB.
[eluser]pmsfo[/eluser]
I think it's only away, i will try to do it and then i will post the code here so that can be add to the codeigniter library. http://www.newitperson.com/
[eluser]cbwd[/eluser]
An old thread, but this gets the size of the default db in MB. Code: /** |
Welcome Guest, Not a member yet? Register Sign In |