From b219cf4c95cb1cded01ca31ce7be907371e8bc08 Mon Sep 17 00:00:00 2001 From: runa Date: Tue, 31 Oct 2006 18:50:45 +0000 Subject: [PATCH] create a db schema for the current connection --- lib/Doctrine/Import/Reader/Db.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/Import/Reader/Db.php b/lib/Doctrine/Import/Reader/Db.php index a644d04f5..97fe793d8 100644 --- a/lib/Doctrine/Import/Reader/Db.php +++ b/lib/Doctrine/Import/Reader/Db.php @@ -66,7 +66,27 @@ class Doctrine_Import_Reader_Db extends Doctrine_Import_Reader */ public function read( ) { - return new Doctrine_Schema(); /* @todo FIXME i am incomplete*/ + $dataDict = Doctrine_Manager::getInstance()->getCurrentConnection()->getDataDict(); + + $schema = new Doctrine_Schema(); /* @todo FIXME i am incomplete*/ + $db = new Doctrine_Schema_Database(); + $schema->addDatabase($db); + + $dbName = 'XXtest'; // @todo FIXME where should we get + + $db->set("name",$dbName); + $tableNames = $dataDict->listTables(); + foreach($tableNames as $tableName){ + $table = new Doctrine_Schema_Table(); + $table->set("name",$tableName); + $tableColumns = $dataDict->listTableColumns($tableName); + foreach($tableColumns as $tableColumn){ + $table->addColumn($tableColumn); + } + $db->addTable($table); + } + + return $schema; }