SlideShare a Scribd company logo
Propel An Open Source ORM
DB Xento System Pvt Ltd.
Presented by
Sachin
Durge
Topics Covered
●What is Propel?
●Preparing your project for Propel.
●Using Propel Models
●Advanced Features
●Future Development
●Wrap-up and Q & A
What is Propel?
Propel is an Object Relational Mapper, which
provides Smart Object Persistence layer. It will be
used as an application Framework Component to
create complex object queries at runtime. And of
course, it's a timesaver toolkit!
Propel as an ORM !
Objects
Object represents real things in life, it have properties
with accessors and mutators methods. As well it
inherits from each other.
Employee
--------------------------
--
EmployeeNo
Name
EmailAddress
Company
---------------------------
CompanyName
OwnerName
Address
Relations
It represents relationship between objects and their properties.
Employee
--------------------------
--
EmployeeNo
Name
EmailAddress
Company
--------------------------
-
CompanyName
OwnerName
Address
Working
Properties organised
as
Objects
Properties organised
as
Relations
Map
Objects Relations
Encapsulate this !
SQL as an interface
SQL provides public access to stored data and
ways to manipulate the data. Database internals
SQL Tables
Objects
SQL seems pretty detailed!
We should totally encapsulate it.
”The Database Class” != ORM
”The Database Class” and the persistence objects
should not stay at the same place.
Deals with Database access.
”Hey, MySQL, execute my queries, here are my
credentials ...”
$strConfig = ”host=localhost;user=admin;pwd=x”;
$objDB = DB::init( $strConfig );
$objDB->execute( 'SELECT * FROM users ' );
Object Relational Mapping
Persists application data.
$user->save();
$objUser = new User();
$objUser->setTitle( 'Mr.' );
$objUser->setName( 'Rajnikant' );
$objUser->setDesignation( 'The Boss' );
$objUser->save();
Does ORM has a new syntax ?
Let's go some ORM on...
In the ideal world...
Object (can) persists.
Object doesn't know HOW and WHERE it persists.
CRUD !
Persisting objects via CRUD
C – create (add)
R – read(select)
U – update( modify)
D – delete (remove)
Following ORM libraries provide
CRUD on object
Propel
Doctrine
Zend
CakePHP
CodeIgniter
Why use ORM Libraries?
The Business
Framework­
friendly (The “M” of MVC)
Rapid Development
Portability
Allows developers to concentrate on the most important
things:
Object Persistence Layer
As Framework Component
OM Generator
Runtime Support
For Developement purpose
Preparing your project for Propel
Install
Build
Execute
Propel Installation
System Requirements
●PHP 5.2+ and PEAR
●Phing (during development only)
●MySQL, PostgreSQL, MSSQL, Oracle, SQlite
PEAR Installer
●pear channel-discover pear.propelorm.org
●sudo pear install -a propel/propel_generator
●sudo pear install -a propel/propel_runtime
Phing Installation
Phing Library installer
●pear channel-discover pear.phing.info
●sudo pear install phing/phing-2.4.2
PHP Configuration in php.ini
ze1_compatibility_mode → Off
magic_quotes_gpc → Off
From PHP code to Database
Create build.properties for general settings.
Write database model in xml schema definitions.
Run propel model and SQL script generate.
Create runtime configuration file.
Run propel to generate object class mapping
and application configuration.
Propel Building Workflow
Design Database in xml (schema.xml)
Configure generator (build.properties)
Configure runtime (runtime-conf.xml)
Build SQL DDL and PHP Classes.
Initialize database.
Use newly create objects in your application.
From PHP to Database
Global Build settings
# Store content in build.properties
propel.project = myapps
propel.database = mysql
propel.database.url = mysql:host=localhost;dbname=mydb
propel.database.user=root
propel.database.password=x
Datamodel Definition
<?xml version="1.0" encoding="UTF-8"?>
<database name="mydb" defaultIdMethod="native">
<table name="books" phpName="Book">
<!-- column and foreign key definitions go here -->
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/>
<column name="title" type="varchar" required="true" size="255" primaryString="true"/>
<column name="isbn" type="varchar" size="24" required="true"/>
</table>
</database>
Propel BuildTime
# Save content in runtime-conf.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<propel>
<datasources>
<datasource id="mydb">
<adapter>mysql</adapter>
<connection>
<dsn>mysql:host=localhost;dbname=mydb</dsn>
<user>root</user>
<password>x</password>
</connection>
</datasource>
</datasources>
</propel>
</config>
Execute :> propel-gen
Building Object Model
> propel-gen om
script generates Object Model classes :
Model : Book.php
Peer : BookPeer.php
Query : BookQuery.php
Model: BaseBook.php
Peer : BaseBookPeer.php
Query: BaseBookQuery.php
Map Class: BookTableMap.php
Building & Executing SQL File
Runtime Connection Config
Writing Runtime XML Settings
#!xml store content as runtime-conf.xml file
<?xml version="1.0" encoding="UTF-8"?>
<config>
<propel>
<datasources>
<datasource id="mydb">
<adapter>mysql</adapter>
<connection>
<dsn>mysql:host=localhost;dbname=mydb</dsn>
<user>root</user>
<password>x</password>
</connection>
</datasource>
</datasources>
</propel>
</config>
Building Runtime Configuration
>propel-gen convert-conf
Convert runtime-conf.xml to myapps-conf.php
Path:
build/conf/myapps.conf.php
Three in One:
> propel-gen
Execute all three command om, sql and convert-conf.
Setting up Propel
<?php
// Include the main Propel script
require_once 'propel/Propel.php';
// Initialize Propel with the runtime configuration
Propel::init("/var/www/myapps/build/conf/bookstore-conf.php");
// Add the generated 'classes' directory to the include path
set_include_path("/var/www/myapps/build/classes" . PATH_SEPARATOR .
get_include_path());
?>
Now you are ready to start using your model classes!
Reverse Engineering
Design Database
Configure generator (build.properties)
Configure runtime (runtime-conf.xml)
Build Schema file and PHP Classes.
Initialize database.
Use newly create objects in your application.
Using ORM Designer
Basic CRUD
Relationships
Relationships between tables are defined using foreign keys.
- Even for systems that don't support true FK constraints.
Propel support single or composite foreign keys.
Support for deletion cascading emulation.
The related objects can be get/set just like simple column
values.
Many To Many, One To One, One To Many and Many To One
Many To One
<?php
$author = new Author();
$author->setFirstName("Leo");
$author->setLastName("Tolstoy");
$author->save();
$book = new Book();
$book->setTitle("War & Peace");
// associate the $author object with the current
$book
$book->setAuthor($author);
$book->save();
One To Many
<?php
$book = new Book();
$book->setTitle("War & Peace");
// associate the $author object with the current $book
$book->save();
$author = new Author();
$author->setFirstName("Leo");
$author->setLastName("Tolstoy");
$author->addBook($book);
$author->save();
Many To Many
<table name="user">
<column name="id" type="INTEGER" primaryKey="true" autoIncrement="true"/>
<column name="name" type="VARCHAR" size="32"/>
</table>
<table name="group">
<column name="id" type="INTEGER" primaryKey="true" autoIncrement="true"/>
<column name="name" type="VARCHAR" size="32"/>
</table>
<table name="user_group" isCrossRef="true">
<column name="user_id" type="INTEGER" primaryKey="true"/>
<column name="group_id" type="INTEGER" primaryKey="true"/>
<foreign-key foreignTable="user">
<reference local="user_id" foreign="id"/>
</foreign-key>
<foreign-key foreignTable="group">
<reference local="group_id" foreign="id"/>
Behaviors
Behaviors are a great way to package model extensions for
reusability. They are the powerful, versatile, fast, and help you
organize your code in a better way.
Aggregate Column
Alternative Coding Standards
Auto Add Primary Key
Timestampable
Sluggable
Soft Delete
Sortable
Nested Set
Inheritance
We always need one model table to extend another model table.
Types:
Single Table Inheritance
Concrete Table Inheritance
Single Inheritance
In this implementation, one table is used for all subclasses.
Essay
Books
Historical
Comics
Schema Definition
<table name="book" abstract=”true”>
<column name="id" type="INTEGER" primaryKey="true" autoIncrement="true"/>
<column name="title" type="VARCHAR" size="100"/>
<column name="class_key" type="INTEGER" inheritance="single">
<inheritance key="1" class="Historical" extends=”Book”/>
<inheritance key="2" class="Essay" extends="Book"/>
<inheritance key="3" class="Comic" extends="Book"/>
</column>
</table>
Single Inheritance
Concrete Inheritance
Concrete Table Inheritance uses one table for each class in the
hierarchy. Each table contains columns for the class and all its
ancestors, so any fields in a superclass are duplicated across the tables
of the subclasses.
Article
Content
News
Video
Question & Answers
Thank You!

More Related Content

PDF
Open Source RAD with OpenERP 7.0
PDF
Propel Your PHP Applications
PDF
Ejb3 Struts Tutorial En
PDF
Ejb3 Struts Tutorial En
PDF
Serve Meals, Not Ingredients - ChefConf 2015
PDF
Serve Meals, Not Ingredients (ChefConf 2015)
PDF
Python Powered Data Science at Pivotal (PyData 2013)
PDF
OpenERP Technical Memento V0.7.3
Open Source RAD with OpenERP 7.0
Propel Your PHP Applications
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial En
Serve Meals, Not Ingredients - ChefConf 2015
Serve Meals, Not Ingredients (ChefConf 2015)
Python Powered Data Science at Pivotal (PyData 2013)
OpenERP Technical Memento V0.7.3

Similar to Propel: A Open Source ORM Model and MVC Framework (20)

PPT
Declarative Development Using Annotations In PHP
PPT
Declarative Development Using Annotations In PHP
PDF
Open erp technical_memento_v0.6.3_a4
PPT
Smoothing Your Java with DSLs
PDF
Breaking The Monotony
PDF
Massively Parallel Processing with Procedural Python (PyData London 2014)
PDF
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
PPTX
Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageContr...
PDF
Supercharging WordPress Development in 2018
PPTX
A brief overview of java frameworks
PPTX
Working with LoopBack Models
PDF
ZendCon2010 Doctrine MongoDB ODM
PPTX
python programming ppt-230111072927-1c7002a5.pptx
PPTX
Oop's in php
PPTX
Hibernate in Nutshell
PDF
Reusando componentes Zope fuera de Zope
PPTX
PYTHON PPT.pptx
PPT
ADO.NET Entity Framework
PDF
Building Content Types with Dexterity
Declarative Development Using Annotations In PHP
Declarative Development Using Annotations In PHP
Open erp technical_memento_v0.6.3_a4
Smoothing Your Java with DSLs
Breaking The Monotony
Massively Parallel Processing with Procedural Python (PyData London 2014)
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
Артем Сыльчук - Хранение полей в Drupal. От CCK к FieldableEntityStorageContr...
Supercharging WordPress Development in 2018
A brief overview of java frameworks
Working with LoopBack Models
ZendCon2010 Doctrine MongoDB ODM
python programming ppt-230111072927-1c7002a5.pptx
Oop's in php
Hibernate in Nutshell
Reusando componentes Zope fuera de Zope
PYTHON PPT.pptx
ADO.NET Entity Framework
Building Content Types with Dexterity
Ad

Recently uploaded (20)

PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Introduction to Artificial Intelligence
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
assetexplorer- product-overview - presentation
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Odoo Companies in India – Driving Business Transformation.pdf
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Reimagine Home Health with the Power of Agentic AI​
Upgrade and Innovation Strategies for SAP ERP Customers
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Navsoft: AI-Powered Business Solutions & Custom Software Development
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Designing Intelligence for the Shop Floor.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
VVF-Customer-Presentation2025-Ver1.9.pptx
Introduction to Artificial Intelligence
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
assetexplorer- product-overview - presentation
Design an Analysis of Algorithms I-SECS-1021-03
Odoo Companies in India – Driving Business Transformation.pdf
Ad

Propel: A Open Source ORM Model and MVC Framework

  • 1. Propel An Open Source ORM DB Xento System Pvt Ltd. Presented by Sachin Durge
  • 2. Topics Covered ●What is Propel? ●Preparing your project for Propel. ●Using Propel Models ●Advanced Features ●Future Development ●Wrap-up and Q & A
  • 3. What is Propel? Propel is an Object Relational Mapper, which provides Smart Object Persistence layer. It will be used as an application Framework Component to create complex object queries at runtime. And of course, it's a timesaver toolkit!
  • 4. Propel as an ORM !
  • 5. Objects Object represents real things in life, it have properties with accessors and mutators methods. As well it inherits from each other. Employee -------------------------- -- EmployeeNo Name EmailAddress Company --------------------------- CompanyName OwnerName Address
  • 6. Relations It represents relationship between objects and their properties. Employee -------------------------- -- EmployeeNo Name EmailAddress Company -------------------------- - CompanyName OwnerName Address Working
  • 8. SQL as an interface SQL provides public access to stored data and ways to manipulate the data. Database internals SQL Tables Objects
  • 9. SQL seems pretty detailed! We should totally encapsulate it.
  • 10. ”The Database Class” != ORM ”The Database Class” and the persistence objects should not stay at the same place. Deals with Database access. ”Hey, MySQL, execute my queries, here are my credentials ...” $strConfig = ”host=localhost;user=admin;pwd=x”; $objDB = DB::init( $strConfig ); $objDB->execute( 'SELECT * FROM users ' );
  • 11. Object Relational Mapping Persists application data. $user->save(); $objUser = new User(); $objUser->setTitle( 'Mr.' ); $objUser->setName( 'Rajnikant' ); $objUser->setDesignation( 'The Boss' ); $objUser->save();
  • 12. Does ORM has a new syntax ? Let's go some ORM on...
  • 13. In the ideal world... Object (can) persists. Object doesn't know HOW and WHERE it persists.
  • 15. Persisting objects via CRUD C – create (add) R – read(select) U – update( modify) D – delete (remove)
  • 16. Following ORM libraries provide CRUD on object Propel Doctrine Zend CakePHP CodeIgniter
  • 17. Why use ORM Libraries? The Business Framework­ friendly (The “M” of MVC) Rapid Development Portability Allows developers to concentrate on the most important things:
  • 19. As Framework Component OM Generator Runtime Support For Developement purpose
  • 20. Preparing your project for Propel Install Build Execute
  • 21. Propel Installation System Requirements ●PHP 5.2+ and PEAR ●Phing (during development only) ●MySQL, PostgreSQL, MSSQL, Oracle, SQlite PEAR Installer ●pear channel-discover pear.propelorm.org ●sudo pear install -a propel/propel_generator ●sudo pear install -a propel/propel_runtime
  • 22. Phing Installation Phing Library installer ●pear channel-discover pear.phing.info ●sudo pear install phing/phing-2.4.2 PHP Configuration in php.ini ze1_compatibility_mode → Off magic_quotes_gpc → Off
  • 23. From PHP code to Database Create build.properties for general settings. Write database model in xml schema definitions. Run propel model and SQL script generate. Create runtime configuration file. Run propel to generate object class mapping and application configuration.
  • 24. Propel Building Workflow Design Database in xml (schema.xml) Configure generator (build.properties) Configure runtime (runtime-conf.xml) Build SQL DDL and PHP Classes. Initialize database. Use newly create objects in your application. From PHP to Database
  • 25. Global Build settings # Store content in build.properties propel.project = myapps propel.database = mysql propel.database.url = mysql:host=localhost;dbname=mydb propel.database.user=root propel.database.password=x
  • 26. Datamodel Definition <?xml version="1.0" encoding="UTF-8"?> <database name="mydb" defaultIdMethod="native"> <table name="books" phpName="Book"> <!-- column and foreign key definitions go here --> <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/> <column name="title" type="varchar" required="true" size="255" primaryString="true"/> <column name="isbn" type="varchar" size="24" required="true"/> </table> </database>
  • 27. Propel BuildTime # Save content in runtime-conf.xml <?xml version="1.0" encoding="UTF-8"?> <config> <propel> <datasources> <datasource id="mydb"> <adapter>mysql</adapter> <connection> <dsn>mysql:host=localhost;dbname=mydb</dsn> <user>root</user> <password>x</password> </connection> </datasource> </datasources> </propel> </config>
  • 28. Execute :> propel-gen Building Object Model > propel-gen om script generates Object Model classes : Model : Book.php Peer : BookPeer.php Query : BookQuery.php Model: BaseBook.php Peer : BaseBookPeer.php Query: BaseBookQuery.php Map Class: BookTableMap.php Building & Executing SQL File
  • 29. Runtime Connection Config Writing Runtime XML Settings #!xml store content as runtime-conf.xml file <?xml version="1.0" encoding="UTF-8"?> <config> <propel> <datasources> <datasource id="mydb"> <adapter>mysql</adapter> <connection> <dsn>mysql:host=localhost;dbname=mydb</dsn> <user>root</user> <password>x</password> </connection> </datasource> </datasources> </propel> </config>
  • 30. Building Runtime Configuration >propel-gen convert-conf Convert runtime-conf.xml to myapps-conf.php Path: build/conf/myapps.conf.php Three in One: > propel-gen Execute all three command om, sql and convert-conf.
  • 31. Setting up Propel <?php // Include the main Propel script require_once 'propel/Propel.php'; // Initialize Propel with the runtime configuration Propel::init("/var/www/myapps/build/conf/bookstore-conf.php"); // Add the generated 'classes' directory to the include path set_include_path("/var/www/myapps/build/classes" . PATH_SEPARATOR . get_include_path()); ?> Now you are ready to start using your model classes!
  • 32. Reverse Engineering Design Database Configure generator (build.properties) Configure runtime (runtime-conf.xml) Build Schema file and PHP Classes. Initialize database. Use newly create objects in your application.
  • 34. Relationships Relationships between tables are defined using foreign keys. - Even for systems that don't support true FK constraints. Propel support single or composite foreign keys. Support for deletion cascading emulation. The related objects can be get/set just like simple column values. Many To Many, One To One, One To Many and Many To One
  • 35. Many To One <?php $author = new Author(); $author->setFirstName("Leo"); $author->setLastName("Tolstoy"); $author->save(); $book = new Book(); $book->setTitle("War & Peace"); // associate the $author object with the current $book $book->setAuthor($author); $book->save();
  • 36. One To Many <?php $book = new Book(); $book->setTitle("War & Peace"); // associate the $author object with the current $book $book->save(); $author = new Author(); $author->setFirstName("Leo"); $author->setLastName("Tolstoy"); $author->addBook($book); $author->save();
  • 37. Many To Many <table name="user"> <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true"/> <column name="name" type="VARCHAR" size="32"/> </table> <table name="group"> <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true"/> <column name="name" type="VARCHAR" size="32"/> </table> <table name="user_group" isCrossRef="true"> <column name="user_id" type="INTEGER" primaryKey="true"/> <column name="group_id" type="INTEGER" primaryKey="true"/> <foreign-key foreignTable="user"> <reference local="user_id" foreign="id"/> </foreign-key> <foreign-key foreignTable="group"> <reference local="group_id" foreign="id"/>
  • 38. Behaviors Behaviors are a great way to package model extensions for reusability. They are the powerful, versatile, fast, and help you organize your code in a better way. Aggregate Column Alternative Coding Standards Auto Add Primary Key Timestampable Sluggable Soft Delete Sortable Nested Set
  • 39. Inheritance We always need one model table to extend another model table. Types: Single Table Inheritance Concrete Table Inheritance
  • 40. Single Inheritance In this implementation, one table is used for all subclasses. Essay Books Historical Comics
  • 41. Schema Definition <table name="book" abstract=”true”> <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true"/> <column name="title" type="VARCHAR" size="100"/> <column name="class_key" type="INTEGER" inheritance="single"> <inheritance key="1" class="Historical" extends=”Book”/> <inheritance key="2" class="Essay" extends="Book"/> <inheritance key="3" class="Comic" extends="Book"/> </column> </table> Single Inheritance
  • 42. Concrete Inheritance Concrete Table Inheritance uses one table for each class in the hierarchy. Each table contains columns for the class and all its ancestors, so any fields in a superclass are duplicated across the tables of the subclasses. Article Content News Video