Up and running with doctrine 2 and zend framework 1

5,039 views

Published on

This speech has been delivered in phpXperts seminar 2010 at Brac University, Dhaka, Bangladesh

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

No Downloads
Views
Total views
5,039
On SlideShare
0
From Embeds
0
Number of Embeds
969
Actions
Shares
0
Downloads
48
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Up and running with doctrine 2 and zend framework 1

  1. 1. Up and running with Doctrine 2 and Zend Framework 1.10 DynamicGuy.com @ferdous github.com/dynamicguy
  2. 2. What is Doctrine? Doctrine is a popular ORM for PHP which works with RDBMS via PHP objects. This is built inspired by Hibernate from JAVA. This acts as an abstraction layer between PHP and RDBMS.
  3. 3. Why should I use it? - Because Nurul Ferdous said? - Does it solve the world terrorism problem? - No, don't be mad on me :) I am gonna explain it.
  4. 4. to SQL or NoSQL! - MySQL - Oracle - PgSQL - SQLite - MsSQL - IBMDB2 - etc - MongoDB - CouchDB
  5. 5. Inserting 20 records with Doctrine
  6. 6. Compare it to some raw PHP code
  7. 7. Insert performance Doctrine 2 = 0.0094 seconds mysql_query = 0.0165 seconds
  8. 8. Doctrine 2 is faster than raw PHP??? Why? The answer is transactions! Doctrine 2 manages our transactions for us and efficiently executes all inserts in a single, short transaction. The raw PHP code executes 1 transaction for each insert.
  9. 9. Here is the same raw PHP code with proper transaction usage
  10. 10. Insert performance * Not trying to say Doctrine 2 is faster than raw PHP code * Demonstrating that simple developer oversights and mis-use can cause the greatest performance problems * This time around it only takes 0.0028 seconds compared to the previous 0.0165 seconds. Pretty cool, huh!
  11. 11. Where to start? - http://doctrine-project.org/projects/orm/2.0/docs/en - http://github.com/dynamicguy/zf1doctrine2
  12. 12. What we need? - ZendX Doctrine2 - Individual Moduler setup (module wise db) - Layout Switcher
  13. 13. File structure in library
  14. 14. File structure in Application
  15. 15. Working with code is often boring. Please don't sleep and bear with me
  16. 16. Configuration for blog module
  17. 17. A typical blog Entity in Doctrine 2
  18. 18. Generating schema from CLI ...blog/bin$ php doctrine orm:schema-tool:create Creating database schema... Database schema created successfully! .../blog/bin$
  19. 19. Fetch all records
  20. 20. Fetch one record
  21. 21. Adding new record
  22. 22. Deleting a record
  23. 23. Code thing is gone! You may wake up now!!
  24. 24. http://DynamicGuy.com hello@dynamicguy.com

×