I switched to using symfony2.0 to develop the project and would like to ask some questions.
某草草
某草草 2017-05-16 16:46:03
0
1
393

I used to use symfony1.4+propel to develop projects, and now I switch to symfony2.0, but I have never used doctrine, but the official default is doctrine and removes propel.
1. What are the advantages of using doctrine? Relative to prop. Projects are systems aspects.
2. When using prop, I found that group by is not very useful, right?
3.How does doctrine handle the many-to-many M:N relationship?

In addition, I post possible problems with doctrine, and I refer to others:
1. Documentation error. Use options to configure additional field options, such as unsigned and default attributes. Official documents and generated yml are specified directly on the field.
2. Foreign keys cannot specify unsigned or default
3. The table relationship is non-identifying relationship

grateful!

某草草
某草草

reply all(1)
刘奇

“标准的”Doctrine所支持的功能,是PDO所支持的各关系型数据库(MySQL,PostgrelSql等)都具备的功能的集合,也就是说,所有A支持而B不支持的,Doctrine默认都不包含,但Doctrine有良好的扩展性和丰富的第三方代码,Baidu里怎么搜不知道,Google里搜Doctrine+Extensions,会有很多收获。

Doctrine多对多的支持还不错,够用。

在Symfony 2里你还是可以用Propel,官网上文档里有专门的一章。

Doctrine和Propel都不错(自己写数据库封装,也可以是好同志),各选各好吧,非要比较的话,可以举一些客观的区别:

  1. Doctrine是Data Mapper+Proxy模式,Propel是Active Record模式(这是个哲学问题);
  2. Doctrine的社区更活跃;
  3. Symfony 2使用Doctrine的Common库来实现的基于注解(annotation)的依赖注入(DI);
  4. Doctrine更现代一些(2.x),对PHP 5.3+的特性支持更好,但Propel也在赶上。

如前述,你所说的unsigned,这个特性不能跨数据库,自然也就没有被默认支持,但如果需要,办法很多,不在此答案中罗嗦。

default也不是能跨数据库的属性,但你可以在Doctrine的Entity类里,为做了映射的成员变量,定义一个默认值就可以了,夫复何求?

Doctrine的承诺就是跨库通用,我认为好的代码就是只做自己承诺的事,从这一点出发,Doctrine还是可以让人放心的。毕竟还有很多人在用PostgreSql或者SQLite,不要用MySQL的思维去强求一致。

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!