From 8c0141b8e31a388111fd1bf57a65a9e804b8472d Mon Sep 17 00:00:00 2001 From: Katsuya Utada Date: Fri, 26 Nov 2010 06:42:53 +0100 Subject: [PATCH] Initial version --- plugins/other/mysql-schema-size | 76 +++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 plugins/other/mysql-schema-size diff --git a/plugins/other/mysql-schema-size b/plugins/other/mysql-schema-size new file mode 100755 index 00000000..08caaca9 --- /dev/null +++ b/plugins/other/mysql-schema-size @@ -0,0 +1,76 @@ +#!/usr/local/bin/php + 1 && $argv[1] == 'authconf') { + exit('yes'); +} + +$dbh = new PDO($dsn,$username,$password); +$mysql = new MysqlTblSize($dbh); + +$stmt = $mysql->getSchemaList(); +$schema_list = array(); +while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $schema = $row['table_schema']; + $text .= "$schema.label $schema\n"; + $schema_list[] = $schema; +} + +if($argc > 1 && $argv[1] == 'config') { + $text = <<getSchemaSize(); +while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $data_length = $row['sum_data_length']; + $schema = $row['table_schema']; + echo "$schema.value $data_length\n"; +} + +class MysqlTblSize { + + private $dbh; + + public function __construct($dbh) { + $this->dbh = $dbh; + } + + public function getSchemaList() { + $sql = <<dbh->prepare($sql); + $stmt->execute(); + return $stmt; + } + + public function getSchemaSize() { + $sql = <<dbh->prepare($sql); + $stmt->execute(); + return $stmt; + } + + +}