Php Object Generator Tutorials
  1. Introduction to POG
  2. Setting up PHP, MySQL etc.
  3. Designing your objects
  4. Generating your code
  5. Description of the generated code
  6. Edit configuration file
  7. The Setup Process
  8. Using the code: Save()
  9. Using the code: Get()
  10. Using the code: SaveNew()
  11. Using the code: GetList()
  12. Using the code: Delete()
  13. Using the code: DeleteList()
  14. Advanced: object relations
  15. Advanced: Set{Parent}()
  16. Advanced: Get{Parent}()
  17. Advanced: Add{Child}()
  18. Advanced: Get{Child}List()
  19. Advanced: Save(deep)
  20. Advanced: Delete(deep)
  21. Advanced: Add{Sibling}()
  22. Advanced: Set{Child}List()
  23. Advanced: Set{Sibling}List()
  24. Advanced: Get{Sibling}List()
  25. Advanced: DeleteList(deep)
  26. Customizing POG-generated code
  27. Customizing: Extending POG Objects
  28. Customizing: Plugins
  29. Examples
  30. Examples: User registration system
  31. Examples: User authentication
  32. Examples: Survey form
  33. Examples: Using POG with AJAX
  34. PDO: Introduction
  35. PDO: SQLite example
  36. PDO: Firebird example
  37. PDO: PostgreSQL example
  38. PDO: MySQL example
  39. PDO: ODBC example
  40. Troubleshooting
  41. Troubleshooting: Data appears encoded
  42. Troubleshooting: Can't regenerate object
  43. Troubleshooting: Can't seem to Save()
  44. Troubleshooting: Can't get object / object attributes from database
  45. Troubleshooting: Can't open zip file on Mac
  46. Troubleshooting: Setup screen is blank
  47. Videos
  48. Appendix: Creating table(s) manually
  49. Appendix: Regenerating objects
  50. Appendix: Generating objects using SOAP
  51. Case Study: Gravity GTD
  52. Case Study: Web Form Factory

Want more Php Object Generator?
Back to the Code Generator
The POG Weblog and RSS feed.
The POG Google group

Advanced: Set{Sibling}List()

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.

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.

//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

POG documentation summary: