- Introduction to POG
- Setting up PHP, MySQL etc.
- Designing your objects
- Generating your code
- Description of the generated code
- Edit configuration file
- The Setup Process
- Using the code: Save()
- Using the code: Get()
- Using the code: SaveNew()
- Using the code: GetList()
- Using the code: Delete()
- Using the code: DeleteList()
- Advanced: object relations
- Advanced: Set{Parent}()
- Advanced: Get{Parent}()
- Advanced: Add{Child}()
- Advanced: Get{Child}List()
- Advanced: Save(deep)
- Advanced: Delete(deep)
- Advanced: Add{Sibling}()
- Advanced: Set{Child}List()
- Advanced: Set{Sibling}List()
- Advanced: Get{Sibling}List()
- Advanced: DeleteList(deep)
- Customizing POG-generated code
- Customizing: Extending POG Objects
- Customizing: Plugins
- Examples
- Examples: User registration system
- Examples: User authentication
- Examples: Survey form
- Examples: Using POG with AJAX
- PDO: Introduction
- PDO: SQLite example
- PDO: Firebird example
- PDO: PostgreSQL example
- PDO: MySQL example
- PDO: ODBC example
- Troubleshooting
- Troubleshooting: Data appears encoded
- Troubleshooting: Can't regenerate object
- Troubleshooting: Can't seem to Save()
- Troubleshooting: Can't get object / object attributes from database
- Troubleshooting: Can't open zip file on Mac
- Troubleshooting: Setup screen is blank
- Videos
- Appendix: Creating table(s) manually
- Appendix: Regenerating objects
- Appendix: Generating objects using SOAP
- Case Study: Gravity GTD
- Case Study: Web Form Factory
Back to the Code Generator
The POG Weblog and RSS feed.
The POG Google group
Advanced: object relations
In addition to the 6 essential CRUD methods, POG can also generate additional methods which facilitate object relations in PHP4 and PHP5.
Object relations are used to define how your objects relate to one another. Even in the simplest web application, when 1 or more objects are used, they are almost always connected in the logical sense. If you have an ‘Blog Article’ object and a ‘Comment’ object, these can be related by the definition: A blog article has many comments or even This comment belongs to this blog article
In the beginning, POG did not provide any out-of-the-box facilities for generating methods that would make object relations easy to program for. One had to manually add the reference attribute of 1 object within another object to establish the relations, much like when you define 2 database tables and connect them using a foreign key.
We then added object relations functionality to POG to accelerate application development and it was very well received.
POG can generate 3 types of connected objects:
PARENT
CHILD
SIBLING
Parent and Child objects are used if your objects have 1 to many or many to 1 relations. The blog and comment example used above is an excellent example of Parent and Child objects.
Sibling objects are used if your objects have many to many relations with each other.
When an object is identified as type ‘Parent’ or ‘Child’ or ‘Sibling’, POG generates the usual 6 CRUD methods as well as additional methods (referred to as relations methods) that accelerate application development even more. What follows is a description of the relations methods as well as code samples that demonstrate how they can be used.
Please note that these additional methods are only generated if a developer specifies that an object
is a Parent, Child or Sibling. Otherwise the object will be generated with only the usual 6 CRUD
methods.
To Specify that an object is a CHILD/PARENT/SIBLING of another, add the OBJECT NAME of target object as an attribute of the referring object and choose {CHILD} / {PARENT} /{SIBLING} from the drop down list. For example, to create an Author/Book parent-child relationship, do the following

Then do not forget to establish the relation in the target object as well:

Specifying relationship both ways is required for the objects to work properly. If the relations are not properly set up. you will get error messages when you run the POG Setup application.
Some blog posts about PHP Object Relations:
http://www.phpobjectgenerator.com/plog/article/136/many-many-relations
http://www.phpobjectgenerator.com/plog/article/102/coming-soon-generate-parent-child-objects
http://www.phpobjectgenerator.com/plog/article/118/php-object-relations-faq
http://www.phpobjectgenerator.com/plog/article/117/php-object-relations


