practical orms
DESCRIPTION
TRANSCRIPT
![Page 1: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/1.jpg)
Practical ORMs
Juozas “Joe” Kaziukėnas, 2010
![Page 2: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/2.jpg)
Who am I?• Juozas Kaziukėnas, Lithuanian• You can call me Joe• 2 years in Edinburgh, UK• Studying in University of Edinburgh• Software developer at 4c, inc. and UAB “Barzda”• Open source developer for Zend Framework and Doctrine
• More info in www.juokaz.com and twitter @juokaz
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 4: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/4.jpg)
5 years ago…• “old-style” PHP• SQL everywhere• Hard to understand• No migrations possible• Not OOP
oAt least not for database interactions
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 6: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/6.jpg)
OOP• Everyone (should have) learnt it at
school/university
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 8: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/8.jpg)
Object relational mapping
• Mapping• PHP objects == database rows• OOP all the way!• Database• Functionality• Features• Implications• Design
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 9: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/9.jpg)
Models• Properties• Behaviour• Business logic• Application layer M (from MVC)
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 10: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/10.jpg)
RelationsUser
Blog posts
Comments
Pingbacks
Groups
Moderators
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 11: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/11.jpg)
Relations OOP style• One-to-one, many-to-one, many-to-many
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 12: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/12.jpg)
Querying• Different than SQL
o DQL in Doctrine
• Working with models, not tableso SELECT * FROM Model_Blog B WHERE B.id = 1
• Very complicated internals• Database driver specific functionality
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 13: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/13.jpg)
Database servers• Works with all of them
o I’m contributing Microsoft SQL server support to Doctrine
• Abstracted access – migrations are possible
• Different databases for different environments
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 15: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/15.jpg)
Speed• Hydration (from SQL results to
objects)• SQL optimization• Memory usage• Lots of classes and very
complicated underlying code
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 17: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/17.jpg)
Other issues• Application architecture• Partitioning models• Lots of small classes• Doesn’t work for all projects
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 19: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/19.jpg)
Why do I need all this?• Faster coding• “Logical” application• Clear business logic• Standards• Not limited to databases• ... Much more
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 20: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/20.jpg)
I want to try it!• PHP implementations:
o Doctrine (and Doctrine 2.0)o Propelo A few more
• Lots of people at #doctrine• Used in production today
Juozas Kaziukėnas / [email protected] / www.juokaz.com
![Page 21: Practical ORMs](https://reader034.vdocument.in/reader034/viewer/2022051312/5479a099b4af9fa8598b473b/html5/thumbnails/21.jpg)
Questions• Want to know more?
o www.juokaz.com – my websiteo dev.juokaz.com – my blogo @juokaz twitter
• Thanks!