extranet/www/services/generateDoctrine.php
2010-05-21 13:15:25 +00:00

29 lines
928 B
PHP

<?php
require_once '../../config/prepend.php';
require_once 'Doctrine.php';
spl_autoload_register(array('Doctrine', 'autoload'));
$argc = $_SERVER['argc'];
$argv = $_SERVER['argv'];
if ($argc != 3) {
print 'usage: '.$argv[0]." <base-de-donnees> <chemin-des-modeles>\n";
exit(1);
}
$base = $argv[1];
$chemin = $argv[2];
if (file_exists($chemin) == false) {
mkdir($chemin);
}
$dsn = 'mysql://'.MYSQL_USER.':'.MYSQL_PASS.'@'.MYSQL_HOST;
${$base.'Conn'} = Doctrine_Manager::connection($dsn.'/'.$base, $base);
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING,
Doctrine::MODEL_LOADING_CONSERVATIVE);
$manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, TRUE);
$manager->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, TRUE);
$manager->setCurrentConnection($base);
print_r(Doctrine::generateModelsFromDb($chemin.'/'.$base, array($base)));
?>