0

Which one of these is the best ORM for PHP in terms of performance? I'd like to use it in Codeigniter framework as well. I'm trying php-activerecord right now, and it doesn't act bad. I took a look to Doctrine2, DataMapper and stuff, but I cannot tell anything about performances until I build a big project (and at that time, it would be too late to change my mind).

Any thoughts?

sixpounder
  • 165
  • 1
  • 2
  • 6
  • 1
    @deceze C'mon, give the man a break. This is very hard to research and he has explained why he can't evaluate his specific use case before he has spent many hours building it around a chosen architecture. – Jannie Theunissen May 24 '12 at 09:54
  • @Jannie Sure, I'm completely sympathetic to that. But this question is simply not well suited for SO. Just look at the result: three responses, containing basically four answers. At this rate he'll have to make a subjective decision for his situation anyway. – deceze May 24 '12 at 10:06
  • here is a practical [php-orm-benchmark](https://github.com/kenjis/php-orm-benchmark/blob/master/README.md#results) results that you can also try inside your own environnement. – Salem Ouerdani Jul 11 '16 at 13:47
  • Maghead ORM is now the fastest one, it generates the plain PDO method code to improve the performance. It's extremely fast, almost close to the PDO code. https://github.com/c9s/forked-php-orm-benchmark https://github.com/maghead/maghead – c9s May 15 '17 at 13:10

3 Answers3

5

If your goal is performance, then use of ORM is the wrong choice to begin with.

ORMs are focused on forcing relational structure to act like objects, which is the source of the problem (the loss of performance, and limitations of API). This is why performance is the thing on which ORMs are NOT focused on. What ORMs are really good at is fast prototyping, but when used in large projects, they usually end up causing technical debt.

Also .. if you are serious about using CodeIgniter, please, read the source, and decide, if this is the quality of code you want to base your project on.

P.S. here are two articles you might find a bit inflammatory, but with relevant points:

tereško
  • 58,060
  • 25
  • 98
  • 150
  • Yes I used CI before and it is great, just what I need. As stated in a comment above, the point is: yes, I know there's an overhead. But given the overhead, I wonder which ORM have the smallest one :) – sixpounder May 24 '12 at 09:13
  • @Sixpounder , the smallest overhead would be if you used [Data Mapper](http://martinfowler.com/eaaCatalog/dataMapper.html) instances in your model layer (do not confused with CI's ORM, with same name, which implements [Active Record](http://martinfowler.com/eaaCatalog/activeRecord.html) pattern). This would not only make thw whole process faster and more flexible, but also reduce the coupling inside the model layer (yes, a proper model is a layer, not a class). Oh .. and i did not ask if you have used CI before .. i recommended for you to read the source of it. – tereško May 24 '12 at 09:18
  • yes, I read the source already, months ago :) thanks for your reply! – sixpounder May 24 '12 at 10:10
  • @Sixpounder , in that case i would suggest for you to watch [clean code talks](http://www.youtube.com/watch?v=4F72VULWFvc&feature=results_main&playnext=1&list=PLED6CA927B41FF5BD) lecture series, to gain some perspective. – tereško May 24 '12 at 10:16
1

Here is a link to GAS ORM vs PHP Active Record (scroll to the bottom)

Result? Gas ORM is way more efficient than PHP Active Record

Laurence
  • 58,936
  • 21
  • 171
  • 212
  • ORM should no be used a "model". Also, the official repository for project seems to be gone from GitHub. – tereško May 24 '12 at 09:13
  • all he is asking for is which Codeigniter ORM is best in terms of performance - and that is what my answer gives (between two options) – Laurence May 24 '12 at 09:15
0

When you start a new project you can get Objects in and out of the database fast, without worrying how you do it. You can also switch DBMS very fast from SQLite on your local dev machine, to MySQL on your testing or staging servers. When the performance part kicks in, your application has already matured a bit, models are somewhat fixed and programlogic is running. Extending the models to use SQL instead of the ORM is more convenient then, because the structure of the project isn't changing (so fast) anymore.

I suggest doctrine.

Integration into CI is painless with Doctrine (there are many posts available on the internet and even some here on SO) so you don't have to learn any fancy new conventions.

Whetever you chose, keep in mind that any ORM will add a massive (compared to what CI's base footprint is) overhead to a very very light-weight framework. So you sacrifice the light-weightness for powerfull database features and more abstraction.

check this link i found out gives very good info http://www.phpandstuff.com/articles/codeigniter-doctrine-from-scratch-day-1-install-and-setup

Rinzler
  • 2,139
  • 1
  • 27
  • 44
  • Obviously it wouldn't be a problem to switch DBMS, but it might be a problem switching libraries (and writing more code in a short time). I like doctrine too, and I know that there will be an overhead with any orm I choose. The question was: given the overhead, which ORM have the smallest one? :) – sixpounder May 24 '12 at 09:10
  • @Sixpounder check the answer on this link i hope it helps http://stackoverflow.com/questions/3438198/which-orm-for-codeigniter – Rinzler May 24 '12 at 09:14