Jump to content

how to generate models using Doctrine help :(


sasori

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:

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

Archived

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

×
×
  • 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.