3

we use Symfony 2 the first time and my company uses an existing MySQL database. Is there a possibility to "import" it in doctrine or can we just use this database and create php/doctrine entities after our existing tables?

If you have some good stuff to read about this topic just post it. Thanks, Pete

3
  • i wouldn't even go there. i think it's best to generate the entities and the database and then create a little php script that imports the data through entities (and not directly to the database). from my experience with doctrine i'd assume it's the best method and most likely to work smoothly Commented Dec 18, 2012 at 10:38
  • stackoverflow.com/a/10614792/1259367 just don't add the filter if you want to import everything :) Commented Dec 18, 2012 at 11:20
  • 1
    After searching for a while i found this: link Commented Dec 18, 2012 at 11:23

1 Answer 1

2

It's obviously better to create database from entities definition, than create enities from existing database. This is a main drawback of Doctrine2...

But it's possible and not so complicated if you have a "sane" existing model. Here is some stuff from my TODO list for model reverse engineering :

  • Use "id" named auto_increment integer as ID of each table,
  • Use SQL TINYINT only for boolean mapped fields ! Use SMALLINT if you need a short int.
  • Using foreign keys as composite key is only permitted from Doctrine 2.1
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.