
- 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{Sibling}List()
By Design, Sibling generated methods have been made very similar to Children generated methods. This was done so as to keep the POG API consistent and easy to remember. As such, Set{Sibling}List is identical to Set{Children}List from the programmer's point of view. However, the code itself handles the information differently, because of the difference in the underlying table structure between children and siblings.
The SetSiblingList() Relations method allows you to associate an array of sibling objects to another sibling object. If the sibling object already had siblings associated with it, those would become orphans (i.e. the association would be removed) as soon as SetSiblingList() is called. This method is useful when you want to either remove the relationship between siblings (by passing an empty array for instance) or if you want to establish a new set of relations between some siblings. After SetSiblingList() is called, the new sibling links are not set until Save() is called. Therefore, one thing to be careful about, is if SetSiblingList() is called on a and Save() is not subsequently called, then the old siblings will become orphans *AND* the new siblings will not be associated. Thus, it is always a good policy to call Save( ) anytime SetSiblingList( ) is called.
PHP:
//Let's assume Book and Author are Siblings
//To associate a list of books associated with an author, simply do the following:
$author = new Author( ) ; //create a parent object
$author -> name = ‘Michael Critchton’ ;
$author -> Save( ) ;
$book = new Book( ) ; //create a child object
$book -> title = " Jurassic Park" ;
$book2 = new Book( ) ; //create a second child object
$book2 -> t i t le = " State of Fear" ;
$bookList = array();
$bookList[] = $book;
$bookList[] = $book2;
$author->SetBookList($bookList); //sets the children list
$author -> Save(); //Save and commit the changes to the database
//To associate a list of books associated with an author, simply do the following:
$author = new Author( ) ; //create a parent object
$author -> name = ‘Michael Critchton’ ;
$author -> Save( ) ;
$book = new Book( ) ; //create a child object
$book -> title = " Jurassic Park" ;
$book2 = new Book( ) ; //create a second child object
$book2 -> t i t le = " State of Fear" ;
$bookList = array();
$bookList[] = $book;
$bookList[] = $book2;
$author->SetBookList($bookList); //sets the children list
$author -> Save(); //Save and commit the changes to the database
The method syntax Set{Sibling}List varies depending on the name of the Sibling object. If your sibling object is called "Author" the method name will be SetAuthorList.