sasori Posted October 21, 2010 Share Posted October 21, 2010 hi, can you guys tell me or type here howto generate models from an existing db using the doctrine 1.2 ? currently, what I did was, I placed the Doctrine folder + Doctrine.php in a directory named e.g test, then in the test directory, I created a file named test1.php , and I added this code include_once('Doctrine.php'); spl_autoload_register(array('Doctrine','autoload')); $manager = Doctrine_Manager::getInstance(); $conn = Doctrine_Manager::connection('mysql://username:password@localhost/dbname','doctrine'); Doctrine::generateModelsFromDb('/test', array('doctrine'), array('classPrefix'=>'Square_Model_') ); then I ran it via shell using "php -f test1.php" , and boom!, nothing happened. actually this code snippet is from a book, I dunno why it's not working Quote Link to comment https://forums.phpfreaks.com/topic/216439-how-to-generate-models-using-doctrine-help/ Share on other sites More sharing options...
trq Posted October 21, 2010 Share Posted October 21, 2010 Doctrine has its own command line interface, take a look at the help for... doctrine generate-models-db Quote Link to comment https://forums.phpfreaks.com/topic/216439-how-to-generate-models-using-doctrine-help/#findComment-1124719 Share on other sites More sharing options...
sasori Posted October 22, 2010 Author Share Posted October 22, 2010 I was able to generate models using this script, slightly modified the one i posted above include_once 'doctrine1/lib/Doctrine.php'; spl_autoload_register(array('Doctrine', 'autoload')); $manager = Doctrine_Manager::getInstance(); $conn = Doctrine_Manager::connection('mysql://root:pass@localhost/dbname','doctrine'); Doctrine::generateModelsFromDb('/a/models', array('doctrine'), array('classPrefix' => 'Square_Model_') ); but I got this error at the cmd , i dunno what it means I deleted the generated models and repeated the same procedure and it doesn't work anymore btw, I placed the Doctrine folder inside the PEAR folder of my PHP installation Quote Link to comment https://forums.phpfreaks.com/topic/216439-how-to-generate-models-using-doctrine-help/#findComment-1125091 Share on other sites More sharing options...
sasori Posted October 23, 2010 Author Share Posted October 23, 2010 problem solved after several trial and errors...the generated models went to the c:\ , Quote Link to comment https://forums.phpfreaks.com/topic/216439-how-to-generate-models-using-doctrine-help/#findComment-1125474 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.