ActiveRecord is good enough

4,306 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,306
On SlideShare
0
From Embeds
0
Number of Embeds
630
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

ActiveRecord is good enough

  1. 1. ActiveRecord is good enough talkie-walkie about DB layers Igor Hlina ( @srigi ) web developer at Websupport.sk
  2. 2. Why? <ul><li>Because of startups – young devs want to bootstrap their startup ideas </li><ul><ul><ul><li>They tend to overcomplicate things at the beginning
  3. 3. (NoSQL, 5 layered Model)
  4. 4. Or they choose poor solution
  5. 5. (TableGateway – Zend Framework v1) </li></ul></ul></ul><li>Discusions about Model layer in czech PHP community
  6. 6. Nette Framework doesn't provide Model layer </li><ul><ul><ul><li>people are using raw Dibi
  7. 7. people are proposing Doctrine 2
  8. 8. people are experimenting with NotORM (NetteDatabase) </li></ul></ul></ul><li>Great experience with Yii ActiveRecord </li></ul>
  9. 9. DB layers experienced in PHP Zend_Db_Table Table gateway Propel (Symfony 1.2) ActiveRecord Doctrine 1 ActiveRecord Doctrine 2 5 layered Model? NotORM (NetteDatabase) SimpleXML like Yii ActiveRecord ActiveRecord
  10. 10. ActiveRecord quicksample * note that User is custom (your) class
  11. 11. Pět vrstev modelu Jan Tichý http://www.phpguru.cz/clanky/pet-vrstev-modelu
  12. 12. Doctrine 2 persisting Entity * note that User is still custom class
  13. 13. Doctrine 2 querying Entity
  14. 14. Playing games Entity, EntityManager, Repository
  15. 15. NotORM quicksample * $articles is NotORM_Result instance, $article is NotORM_Row instance
  16. 16. Custom AR class the Yii way storing quering custom methods
  17. 17. GOD object? maybe, but allows rapid project prototyping <ul><li>querying for AR instances </li></ul>* note that we're not explicitly instancing User class
  18. 18. Querying – Criteria builder
  19. 19. Querying – Criteria builder conditional assembly
  20. 20. <ul><li>relational Model </li></ul>GOD object? maybe, but allows rapid project prototyping
  21. 21. GOD object? maybe, but allows rapid project prototyping <ul><li>validation </li></ul>* User class
  22. 22. <ul><li>events </li></ul>GOD object? maybe, but allows rapid project prototyping * User class
  23. 23. Fallback to SQL advanced AR allows smarter code
  24. 24. More tricks with relations
  25. 25. ActiveRecord popularity favorite web frameworks <ul><li>Ruby-on-rails ✓
  26. 26. asp.net-mvc ✓
  27. 27. Django ✓
  28. 28. Zend framework
  29. 29. jsf
  30. 30. gwt
  31. 31. Cakephp ✓
  32. 32. Codeigniter ✓
  33. 33. Grails ✓
  34. 34. Spring-mvc
  35. 35. Symfony ✓
  36. 36. Struts
  37. 37. Kohana ✓
  38. 38. Pylons ✓
  39. 39. Sinatra ✓
  40. 40. dotnetnuke
  41. 41. Wicket ✓
  42. 42. Lift
  43. 43. Yii ✓
  44. 44. Cherrypy ✓
  45. 45. Web2py ✓ </li></ul><ul>✓ native ✓ by library AR solution not found </ul><ul>StackOverflow’s top web frameworks </ul>
  46. 46. ActiveRecord conclusion <ul><li>All needed functionality in one place
  47. 47. Allows optimized querying (can be fast)
  48. 48. Easy to understand, easy to use
  49. 49. Popularity (verified concept) </li></ul>
  50. 50. Thank you Igor Hlina ( @srigi ) questions?

×