开发者

Under which conditions does it make sense to use Doctrine 2 instead of PDO?

开发者 https://www.devze.com 2023-03-26 10:55 出处:网络
My question is not aiming at ORMs in general but specifically Doctrine 2! Every mildly complex PHP-application uses a database.

My question is not aiming at ORMs in general but specifically Doctrine 2!

Every mildly complex PHP-application uses a database.

And as much as it makes sense to seperate M, V and C it makes sense to seperate the M into DB-access-level and high-level objects.

Now I just had a superficial l开发者_StackOverflow中文版ook at Doctrine 2 and it certainly seems all nice and dandy but so far I cannot see any reason what I will gain from this tool compared to using PDO-features like FETCH_CLASS, FETCH_OBJECT and FETCH_INTO combined with a reasonably structured collection of classes.

Of course I would have to write more code myself; but the difference does seem far from the speed I gain when developing with a framework instead of building a PHP-app from the scratch.

So if you know Doctrine 2, then maybe you can tell me under what conditions Doctrine 2 should be seriously considered, b/c:

it will speed up development substantially (due to specific features)

this is the only reason that makes sense in my opinion.


You're correct, it does speed up development by a substantial amount. The other comparison is 'preference' - Doctrine 2 feels more truly 'object orientated'. It's also important to note that Doctrine 2 uses transactions to execute queries to speed up execution time and although this can be done using PDO as you mentioned previously it requires you to write more code.

I guess it's like having your own PHP libs and using frameworks. It just 'speeds up' the development process and therefore it's an obvious winner with people writing large applications.

0

精彩评论

暂无评论...
验证码 换一张
取 消