2009-05-04 14:26:54 +00:00
|
|
|
<?php
|
2009-05-07 14:31:17 +00:00
|
|
|
require_once realpath(dirname(__FILE__)).'/../../config/prepend.php';
|
|
|
|
require_once 'Doctrine.php';
|
|
|
|
spl_autoload_register(array('Doctrine', 'autoload'));
|
2009-05-12 13:40:22 +00:00
|
|
|
|
2010-02-10 17:27:03 +00:00
|
|
|
$dbs = array('graydon', 'intersud', 'sdv1');
|
|
|
|
$dsn = 'mysql://'.MYSQL_USER.':'.MYSQL_PASS.'@'.MYSQL_HOST;
|
2010-03-16 10:58:40 +00:00
|
|
|
$modelsPath = PATH_DATA.'/models';
|
2010-02-10 17:27:03 +00:00
|
|
|
|
|
|
|
foreach($dbs as $db)
|
|
|
|
{
|
2010-03-16 10:58:40 +00:00
|
|
|
${$db.'Conn'} = Doctrine_Manager::connection($dsn.'/'.$db, $db);
|
2010-02-10 17:27:03 +00:00
|
|
|
}
|
2009-05-12 13:40:22 +00:00
|
|
|
|
2009-05-07 14:31:17 +00:00
|
|
|
$manager = Doctrine_Manager::getInstance();
|
|
|
|
$manager->setAttribute( Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
|
2010-03-16 10:58:40 +00:00
|
|
|
$manager->setAttribute( Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, TRUE );
|
2009-05-07 14:31:17 +00:00
|
|
|
$manager->setAttribute( Doctrine::ATTR_USE_NATIVE_ENUM, TRUE);
|
2009-05-12 13:40:22 +00:00
|
|
|
|
2010-02-10 17:27:03 +00:00
|
|
|
if(!file_exists($modelsPath)) mkdir($modelsPath);
|
2009-05-13 16:04:48 +00:00
|
|
|
|
2010-02-10 17:27:03 +00:00
|
|
|
foreach($dbs as $db)
|
|
|
|
{
|
|
|
|
echo 'Génération models '.$db;
|
|
|
|
$manager->setCurrentConnection($db);
|
|
|
|
$generate = Doctrine::generateModelsFromDb($modelsPath.'/'.$db, array($db));
|
|
|
|
echo '<pre>';
|
|
|
|
print_r($generate);
|
|
|
|
echo '</pre>';
|
|
|
|
echo '<br/>';
|
|
|
|
}
|
|
|
|
?>
|