From 6f7fdef0f500cd4bb540affd3bc1482243f337c1 Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 24 Feb 2016 23:18:07 +0100 Subject: * Prado 3.3.0 --- lib/prado/framework/Wsat/TWsatBaseGenerator.php | 82 +++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 lib/prado/framework/Wsat/TWsatBaseGenerator.php (limited to 'lib/prado/framework/Wsat/TWsatBaseGenerator.php') diff --git a/lib/prado/framework/Wsat/TWsatBaseGenerator.php b/lib/prado/framework/Wsat/TWsatBaseGenerator.php new file mode 100644 index 0000000..a87ea37 --- /dev/null +++ b/lib/prado/framework/Wsat/TWsatBaseGenerator.php @@ -0,0 +1,82 @@ + + * @link https://github.com/pradosoft/prado + * @copyright Copyright © 2005-2015 The PRADO Group + * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT + * @version $Id$ + * @since 3.3 + * @package System.Wsat + */ +Prado::using('System.Data.Common.TDbMetaData'); + +class TWsatBaseGenerator +{ + + /** + * @return TDbMetaData for retrieving metadata information, such as + * table and columns information, from a database connection. + */ + protected $_dbMetaData; + + /** + * Output folder where AR classes will be saved. + */ + protected $_opFile; + + function __construct() + { + if (!class_exists("TActiveRecordManager", false)) + throw new Exception("You need to enable the ActiveRecord module in your application configuration file."); + $ar_manager = TActiveRecordManager::getInstance(); + $_conn = $ar_manager->getDbConnection(); + $_conn->Active = true; + $this->_dbMetaData = TDbMetaData::getInstance($_conn); + } + + public function setOpFile($op_file_namespace) + { + $op_file = Prado::getPathOfNamespace($op_file_namespace); + if (empty($op_file)) + throw new Exception("You need to fix your output folder namespace."); + if (!is_dir($op_file)) + mkdir($op_file, 0777, true); + $this->_opFile = $op_file; + } + + public function renderAllTablesInformation() + { + foreach ($this->getAllTableNames() as $table_name) + { + echo $table_name . "
"; + $tableInfo = $this->_dbMetaData->getTableInfo($table_name); + echo "Table info:" . "
"; + echo "
";
+            print_r($tableInfo);
+            echo "
"; + } + } + + public function getAllTableNames() + { + $tableNames = $this->_dbMetaData->findTableNames(); + $index = array_search('pradocache', $tableNames); + if ($index) + array_splice($tableNames, $index, 1); + return $tableNames; + } + + public static function pr($data) + { + echo "
";
+        print_r($data);
+        echo "
"; + } + + protected function eq($data) + { + return '"' . $data . '"'; + } + +} -- cgit v1.2.3