Jump to content

Archived

This topic is now archived and is closed to further replies.

sasori

how to generate models using Doctrine help :(

Recommended Posts

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. :wtf:

actually this  code snippet is from a book, I dunno why it's not working  :shrug:

Share this post


Link to post
Share on other sites

Doctrine has its own command line interface, take a look at the help for...

 

doctrine generate-models-db

Share this post


Link to post
Share on other sites

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

 

2qbzntf.jpg

 

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

Share this post


Link to post
Share on other sites

problem solved after several trial and errors...the generated models went to the c:\  ,

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.