Welcome Guest, Not a member yet? Register   Sign In
Replace Code Igniter's database layer with Doctrine 2
#1

[eluser]Funny Bunny[/eluser]
Hello,

Coming from a Java background I pleasantly surprised at the way Doctrine 2 integrates with CI and especially the way it integrates with Code Igniter. So surprised that I wondered how hard it would be to replace Code Igniter's database layer with Doctrine, both for internal framework use (thinking database backed Sessions) and external use.

Has anyone tried this? What would be the pros and cons?
#2

[eluser]Cristian Gilè[/eluser]
http://www.phpandstuff.com/articles/code...-and-setup


Cristian Gilè
#3

[eluser]Funny Bunny[/eluser]
I don't mean just using Doctrine with CI, I mean completely ripping out the guts of CI, the whole database layer, and replacing it with Doctrine.
#4

[eluser]WanWizard[/eluser]
Have you even looked into this before asking?

As far as I can see, Doctrine doesn't use CI's database layer at all. It imports CI's database config, and uses PDO to directly connect to the databases...

And you don't want to replace it, believe me. Doctrine is dead-slow compared to CI's database layer, it's a bit pointless trying to convert for example sessions to use Doctrine.
#5

[eluser]Funny Bunny[/eluser]
Is it slower than Doctrine 2?
#6

[eluser]WanWizard[/eluser]
Any ORM is always slower than CI's simple abstaction layer, which in turn is slower than writing your query's manually and calling mysql_query() directly.
There is simply much more code involved to construct and execute the query. There are files (models) to be loaded, classes to be instantiated, etc.

The quickest code is the code that doesn't have to be executed (well, not entirely true, the quickest code is the code that isn't there...).

What you gain in flexibility, standardisation and easy maintance, you loose in speed. This is true for any time of abstraction. It's up to you do judge which is more important. For me, ORM for the application is a no-brainer, development is faster, and application maintenance takes a lot less time. Definately outweights coding by hand. And the cost of a bigger server (due to the performance loss) is in most cases much less then the extra development cost of maintaining an app with hand coded queries all over the place.

For "internal" stuff, I don't think so. There is no gain to rewrite the session library to use an ORM model. It's set-and-forget, you only create a maintenance issue when you want to upgrade CI at a later stage.




Theme © iAndrew 2016 - Forum software by © MyBB