This document discusses using Doctrine 2 as an ORM with Zend Framework 1.10. It explains what Doctrine is, why it should be used, and how to set it up with Zend Framework. It provides examples of inserting records with Doctrine 2 versus raw PHP code, showing Doctrine 2 is faster due to transaction handling. It also demonstrates how to configure a blog module with Doctrine 2, define entities, generate the schema, and perform basic CRUD operations.
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Up and running with doctrine 2 and zend framework 1
1. Up and running with Doctrine 2 and
Zend Framework 1.10
DynamicGuy.com
@ferdous
github.com/dynamicguy
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. 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. to SQL or NoSQL!
- MySQL
- Oracle
- PgSQL
- SQLite
- MsSQL
- IBMDB2
- etc
- MongoDB
- CouchDB
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. Here is the same raw PHP code with
proper transaction usage
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. Where to start?
- http://doctrine-project.org/projects/orm/2.0/docs/en
- http://github.com/dynamicguy/zf1doctrine2
12. What we need?
- ZendX Doctrine2
- Individual Moduler setup (module wise db)
- Layout Switcher