简体   繁体   中英

Switch symfony 1.4 from Doctrine to Propel

如何正确地将新安装的Symfony 1.4框架从Doctrine(默认情况下配置为)转换为Propel?

If you create new (fresh) project...

symfony generate:project xxx --orm=Propel

The easiest thing :)

If you want to change existing project - you have to dig in configuration file and enable propel plugin.

Your configuration file should look similar to:

// config/ProjectConfiguration.class.php
public function setup()
{
  $this->enablePlugins('sfPropelPlugin');
  ...
}

(based on Symfony page, you should dig it next time - especially Practical Symfony )

如果您喜欢面向对象的语法,请使用Propel。

If you like chained object method calls that look like SQL statements, use Doctrine. If you like real objects that hide SQL, use Propel.

If you like creating criteria objects that then render themselves as WHERE clauses, use Propel. If you like creating WHERE clauses similar to SQL, use Doctrine.

You can use both at the same time, too. Not recommended, but if you use plugins like apostrophe that only use Doctrine, you might not have a choice.

Replying to the contributors here who wholly recommend Doctrine: the decision is not clear cut, in my view. Propel now also supports chainable query methods, so if you like that approach then both are still in play. Also, the Propel team maintain that the generated nature of model objects makes it faster to run for most use-cases than Doctrine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM