- 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: Set{Parent}()
The SetParent () Relations method allows you to associate a parent object to a child object. When a child object is generated, POG automatically adds a ParentId attribute to the child object. When SetParent() is called, POG essentially associates the object id of the parent to the child
PHP:
//To set an Author object as the parent of a child object:
$author = new Author ( ) ; //create a parent object
$author -> name = ‘Mi chael Cri tchton’;
$author -> Save( ) ;
$book = new Book( ) ; //create a child object
$book -> t i t le = " State of Fear" ;
$book -> SetAuthor ($author ) ; // this associates the parent to the child
$book -> Save( ) ;
/*
Not e:
chi ld - > SetParent i s a lmost equivalent to parent -> AddChi ld
.
The main di fference is that SetParent requires that the parent object be previously saved before associat ing a chi ld to i t . Depending on the code context , the developer can choose whi ch method is most convenient to him/her .
*/
$author = new Author ( ) ; //create a parent object
$author -> name = ‘Mi chael Cri tchton’;
$author -> Save( ) ;
$book = new Book( ) ; //create a child object
$book -> t i t le = " State of Fear" ;
$book -> SetAuthor ($author ) ; // this associates the parent to the child
$book -> Save( ) ;
/*
Not e:
chi ld - > SetParent i s a lmost equivalent to parent -> AddChi ld
.
The main di fference is that SetParent requires that the parent object be previously saved before associat ing a chi ld to i t . Depending on the code context , the developer can choose whi ch method is most convenient to him/her .
*/



The method syntax Set{Parent} varies depending on the name of the Parent object. If your parent object is called "Book" the method name will be SetBook.