Skip to content

Commit

Permalink
Ticket 3, Enhanced create-tables task to show the number of executed …
Browse files Browse the repository at this point in the history
…queries and connections, or show an error when no query is found
  • Loading branch information
beberlei committed May 26, 2010
1 parent 3f19b1c commit d0b7ceb
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions library/ZFDoctrine/Tool/DoctrineProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,23 @@ public function createTables()
try {
$models = ZFDoctrine_Core::getLoadedModels();
$models = ZFDoctrine_Core::filterInvalidModels($models);

$export = Doctrine_Manager::connection()->export;
$export->exportClasses($models);

$this->_print("Successfully created tables from model.", array('color' => 'green'));
$queries = $export->exportSortedClassesSql($models);
$countSql = 0;
foreach ($queries as $connectionName => $sql) {
$countSql += count($sql);
}

if ($countSql) {
$export->exportClasses($models);

$this->_print("Successfully created tables from model.", array('color' => 'green'));
$this->_print("Executing " . $countSql . " queries for " . count($queries) . " connections.", array('color' => 'green'));
} else {
$this->_print("No sql queries found to create tables from.", array('color' => array('white', 'bgRed')));
$this->_print("Have you generated a model from your YAML schema?", array('color' => array('white', 'bgRed')));
}
} catch(Exception $e) {
$this->_print("Error while creating tables from model: ".$e->getMessage(), array('color' => array('white', 'bgRed')));

Expand Down

0 comments on commit d0b7ceb

Please sign in to comment.