Ask your Symfony questions! Pay money and get answers fast! (more info)

How to use Doctrine and Propel in same project? Symfony

  • SOLVED

I have created a Sf 1.4 app in Doctrine (MySQL) however, I need to read and write to a legacy MSSQL database.

After doing some research, it seems as though the best way to connect to the MSSQL database using Symfony is using [[LINK href="http://trac.symfony-project.org/wiki/HowToConnectToMSSQLServer"]]this method[[/LINK]]: (Propel 1.5 + pdo_sqlsrv) which I have done successfully.

Is there any way that I can run this Propel solution along side Doctrine without modifying the symfony core? Open to other suggestions...

Answers (1)

2010-10-24

Marcos IbaƱez answers:

Apparently using Propel and Doctrine in the same project is pretty straightforward, just enable both modules in your ProjectConfiguration and you ready to go.

Remember to add the connection information for the new connection (Propel in your case) to your databases.yml, and of course remember that you can't use both ORMs on the same table.

The only issue you will have problems with is when you try to clear the cache, Symfony it's going to complain about configure:database being defined twice, that's because both Prople and Doctrine define it, you'll just have to rename one (I recommend the sfPropel15Plugin one, it should be in plugins/sfPropel15Plugin/sfPropelConfigureDatabaseTask.class.php) of them.

I know it's doesn't feel right to modify the core, but in this case it's just a plugin, and the change is really trivial so it won't be very difficult to apply it if you update your plugin.

Regards.