How to add new entites & table to exists projects

New topics about Symfony 2 should go here

Moderators: dcobalt, tiagojsag

How to add new entites & table to exists projects

Postby khiemnd » Thu Apr 12, 2012 4:37 am

Hi all,

I have a problem. The first I generate my entities from exists database. Follow by link http://symfony.com/doc/current/cookbook/doctrine/reverse_engineering.html

Now I want to add new table to database & generate entity for that table. How can I do it?

I try to re-generate it by using two command

php app/console doctrine:mapping:import MyBlogBundle annotation
php app/console doctrine:generate:entities MyBlogBundle

But it created new entites & overwrite my old entites.

Please help me, thank in advance.
khiemnd
Junior Member
 
Posts: 9
Joined: Sat Mar 24, 2012 3:06 pm

Re: How to add new entites & table to exists projects

Postby Krudie » Thu Apr 12, 2012 12:04 pm

Yeah I like to work in that way too, but this is not the exact Sf2 and mainly Doctrine way to do things.

php app/console doctrine:mapping:import MyBlogBundle annotation

This one reverse engineer all your SQL tables and import/describe them in your specified bundle in the specified format.

php app/console doctrine:generate:entities MyBlogBundle

This one generate the doctrine php objects/entites.

Between those two actions, you may want to manually delete all the generated tables descriptions that doesn't belong in your bundle. I'm not sure using the annotation format is a good idea here. Personnaly, I use yml, and I manually delete in command line or FTP the generated .yml (something in your bundle directory/Resosucres/doctrine/orm/xxx.yml if I remember correctly). Then I generate the bundle entites.


If you have customized your entities, check this question I asked a few days ago: viewtopic.php?f=23&t=40767
Lukis member answered me, but I still didn't had the time to test it furthermore. Good luck!
User avatar
Krudie
Junior Member
 
Posts: 17
Joined: Thu Jul 21, 2011 4:56 pm

Re: How to add new entites & table to exists projects

Postby khiemnd » Wed May 23, 2012 6:34 pm

Thanks in advance, It's resovled. :D~:-D~:grin:
khiemnd
Junior Member
 
Posts: 9
Joined: Sat Mar 24, 2012 3:06 pm


Return to General Symfony 2 discussion

Who is online

Users browsing this forum: No registered users and 7 guests