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

Designing your objects

Depending on the project, the objects you’ll need will be different. For instance, if you’re writing a registration system for a website, then, one of the object you’ll need is a “USER” object. On the other hand, if you’re writing a library-type application, one of the object you’ll need is a “BOOK” object.

Then you need to decide what attributes your object will store. For example, if you decide to create a “BOOK” object, you’ll probably want to store the following attributes for the book:

  1. bookTitle
  2. author
  3. numberOfPages
  4. isbn
  5. price

If you’ve ever done any programming, you should know that one thing that always happens is that requirements change and evolve. A week or two after starting your project, you’ll suddenly be notified (or realize on your own) that you need a few other attributes such as the year the book has been published. This is where the @link feature in POG becomes really handy. (read more about @link)

Once you’re satisfied with how your object looks, you can Generate the code for it.

Note: Smaller Objects Equals Faster Code.
Keep your objects relatively small. Having smaller objects equals faster code. For example, if you’re designing a registration system where users can upload a picture of themselves, the easiest way to do this is to create a User object with a picture attribute. There’s nothing wrong with that, and it works fine. However, if you want faster code, you should split your object into a User and an Image object. In this case, you would have an image id attribute that links the user object to the image object. This way, whenever you’re trying to get a list of user names from the User table in the database, you’re not retrieving large amounts of data unnecessarily.

The rule of thumb is: Whenever you’re storing multimedia files as such as video, pictures and music, do not store them as attributes of another object. Instead, store them as objects themselves.

We regularly give pointers and tips about code generation and PHP objects in the POG Blog. We encourage you to subscribe to our RSS feed so you’re kept up-to-date with anything POG-related.

Proceed to next step of the tutorial ››

POG documentation summary: