Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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