I like CodeIgniter's Active Record and just how nicely it enables my needed database queries.
But I have been reading through about ORMs like Doctrine. After I read Doctrine's documentation, it doesn't appear as obvious for Active Record, and that i can't see what causes it to be better (if it's).
Exactly what does Doctrine allow that's difficult with Active Record? Does Doctrine result in the same job faster, simpler, better? Or will it do things Active Record canrrrt do?
Best could be if people could publish good examples of tasks showing what we are speaking about.
To begin with, what Doctrine are you currently speaking about, one or two ?
There's an enormous difference. The only real factor the two share is they are generally full-fledged ORM-s. Otherwise there really is not any link between the 2.
Doctrine 1 is dependant on ActiveRecords, Doctrine 2 relies od Data mapper pattern.
Both can perform same things, but you will find some significant variations between your two.
In most cases Data mapper is less "developer-friendly" but must have better performances. Why? Really it's really quite simple. With active records each entity knows everything "around" itself, relation along with other organizations etc. With data mapper, organizations are dumb and light-weight, there's a central entity (EntityManager/UnitOfWork in Doctrine2) which handles all of the relation mapping. So when it comes to memory usage and gratifaction Data mapper ought to be faster.
The Doctrine men state that Doctrine2 is really a least 50% faster that Doctrine1 (you will find other variations too, not only the look pattern).
If you think up for this, you may also implement ActiveRecords over Doctrine2 data mapper. See this blog post. I am by using this approach only for the expansion phase, to help keep very little code as you possibly can. Once it will get into production I'll get rid of the additional ActiveRecords layer, and rollback towards the default data mapper of Doctrine2.
Therefore the conclusion is you can fit everything in with both, but in the same manner you can say that can be done everything with raw SQL. If you're a beginner within the ORM world, I recommend choosing ActiveRecords, since it is easy and (usually) requires less code. However, if you're creating a large, complex model, I believe data mapper is the foremost option.
Maybe I acquired a problem, but this is the way I understood it.
For the comparison between CodeIgniters ActiveRecords and Doctrine (one or two), I can not really say, because I not used at all CodeIgniter. One factor I am certain, Doctrine offers quite a bit more features that CodeIgniters default ORM. For instance: result hydration, inheritance (single table, class table), prefetching, lasy loading, extra lasy loading, extensions, behaviors, optimisation, proxies, datetime handling... It's a massive and full-fledged ORM with many different features, while my knowledge about any "default framework ORM" is the fact that their primary goal will be simple as you possibly can, so a new could possibly get a practice it effortlessly. Doctrine is really a mighty animal, and without a doubt can perform a many things inside a more effective and/or realistically more right way compared to build in CodeIgniter ORM. However, that's takes additional time to understand and code, which is an enormous library, with 1000's of files, so simply to get everything running adds some overhead in comparison to some lighter alternative.