RSS feed - Using POG with Flex
- Optimizing your web application
- Regenerating large objects
- PHP4 or PHP5
- New and Improved
- Evolution of a cube
- POG Museum
- POG 3.0 alpha
- Initial Performance results Part 2
- Initial performance results
- Proposal: POG 3.0 object model
- Suggest a feature
- A new year, A new POG release
- Many-Many relations
- POG 2.5 Released
- POG 2.5 beta
- Automatic table alignment
- New version: 2.1.2 released
- RSS should work well now
- RSS feed glitches
- What's new in 2.1.0
- PHP Objects 2.1.0 (preview)
- PHP Object relations FAQ
- PHP Object Relations
- Searching base64 encoded text
- How to debug POG-generated objects
- POG UI Tips
- Featuring Of Interest links
- PHP CRUD
- POG 2.0.1: A better code generator
- A look at the POG SOAP API
- POG 2.0.0 released
- Coming soon: Generate parent-child objects
- Generated abstraction v/s dynamic abstraction
- Zend Framework preview
- Coming soon: Generate Objects through SOAP
- Easily save images and files to a database
- PHP, Paypal & POG
- Five advanced Code Generator tips
- PHP Pagination using generated objects
- PHP Code Generator benchmarks
- Representing database objects using an AJAX Tree interface
- Using SETUP in a production environment
- Description of the generated object package
- Introducing PHP Object Generator version 1.6
- Using AJAX and PHP Object Generator
- When to use Object->SaveNew()
- Generating PHP objects in 2006
- Happy Holidays
- A short video of the POG Setup process
- A sneak peek at POG 1.6
- POG Tip: Field limits
- Previous versions.
- Searching the blog and tutorials sections
- Generating code with "Other" SQL data types
- Five general POG tips
- POG source code locations
- Microsoft SQL 2005 Express Edition
- Impatiently awaiting PHP 5.1 and PDO
- Php Object Generator goes open source
- POG generates PDO compatible code
- Oracle to offer free database
- POG Google group
- Database Wrappers and POG
- Revisions
- The generator blog
- An explanation of the 'Escape' function.
- Mirror, mirror
- Using POG to solve real world problems
- A php object-relational database tool
- A simple and flexible Object Oriented approach to PHP
Back to the Code Generator
The POG Google group
The POG tutorials/code samples
The POG mirror site
PHP Object Relations
written 700 days agoAfter some discussion in the POG Google group, it seems that we haven’t done a good enough job yet, explaining how to use POG’s optional ability to generate object-relations code. So, here it goes:
In addition to the basic 5 CRUD methods (Get, Save, GetList, SaveNew and Delete), POG is able to generate additional methods for “connected objects”. These additional methods are only generated if, upon generation, you have chosen 1 or more attributes to be of type “Child” or “Parent” from the drop-down list in the POG interface.
More often than not, objects are related to each-other in an application, so it makes sense for developers to take advantage of these generated methods. However, a developer can still decide to implement object relations without going through POG’s child/parent concept. In this case, the developer would then generate objects containing attributes that can be used as foreign keys to match them with other objects.
Explanation of POG’s parent/child concept.
POG’s parent/child concept is quite simple and is essentially an implementation of 1-to-many and many-to-1relations. A parent object can have many children (1-to-many). Many children can refer to the same parent (many-to-1). Using POG to generate Many-to-many relations is a little less obvious and currently not supported out-of-the-box, but we’re working to correct this in the next release.
Programmatic meaning:
It might be worth mentioning what a Parent or Child attribute mean on a programmatic level in POG.
RULE A
When object “P” contains a Child attribute “C”, it means that P will have:
1. a method GetCList() will be generated. GetCList returns a list of all children for parent P.
2. a method AddC() will be generated. AddC() will add any child C to the list of children belonging to P.
3. the ability to save all children, grand-children, grand-grand children etc. recursively through Save($deep).
4. the ability to delete all children, grand-children, grand-grand children etc. recursively through Delete($deep).
RULE B
When an object “C” contains a Parent attribute “P”, it means that C will have:
1. an attribute pId which refers to the Id of the Parent object.
2. A GetP() method which fetches the parent object.
3. A SetP() method which sets the parent object.
How to use POG’s interface to generate object relations. (Examples)
The rule of thumb is: Whenever an object P has a attribute C of type {Child}, the child object C must also have an attribute P of type {Parent}.
Example #1.
- An author has a name and 1 or more books
- A book has a title and only 1 author
- A publishing Company has a name and 1 or more authors
Solution:
Create an “Author” object with the following attributes:
- Book ({Child})
- Publisher ({Parent})
- name (VARCHAR)
Create a “Book” object with the following attributes:
- Author ({Parent})
- title (VARCHAR)
Create a “Publisher” object with the following attributes:
- Author ({Child})
- name (VARCHAR)
Example #2
- A project has a name, a due date and 1 or more developers
- A task has a title and belongs to 1 developer
- A developer has a name, a title and one or more tasks.
Solution:
Create a “Project” object with the following attributes:
- name (VARCHAR)
- dueDate (VARCHAR)
- Developer ({Child})
Create a “Task” object with the following attributes:
- title (VARCHAR)
- Developer ({Parent})
Create a “Developer” object with the following attributes:
- name (VARCHAR)
- title (VARCHAR)
- Task ({Child})
- Project ({Parent})
Over the next little while, we’ll be adding some more info about Relations to the POG documentation as well as to the blog, and we hope some of you find it useful.

This is a weblog about the Php Object Generator (POG) project, OO PHP, databases and Php code generators in general.
Php Object Generator, (POG) is an open source PHP code generator which automatically generates clean & tested Object Oriented code for your PHP4/PHP5 application.
Subscribe to our RSS feed
Feedback, Feature Requests, Bugs to:
The POG Google group
Send us a Hello through email
The Example #2 on PHP Object Relations has a little bug. A developer has a name, a title and one or more tasks ({Child}), and belongs to one project ({Parent}). Therefore, the “Developer” object must be assigned as the ({Child}) of the “Project” object rather than the “Task” object.
Best Regards,
Chris
Technical Director
ProFormPlus – Secure Online Forms
— Chris Kunze May 1, 03:14 PM #