extranet/includes/giant/generateDoctrine.php
2010-08-31 13:55:19 +00:00

34 lines
1.0 KiB
PHP

<?php
define('MYSQL_USER', 'root');
define('MYSQL_PASS', '');
define('MYSQL_HOST', 'localhost');
define('PATH_SITE', realpath(dirname(__FILE__).'/../../'));
require_once PATH_SITE.'/includes/dbbootstrap.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)));
?>