Your Tables as PHP Objects

The Code Generator will more or less create a PHP object for each table in your database. For our three main tables (login, person and project), the Code Generator created the following PHP classes:
  • Login
  • LoginGen
  • Person
  • PersonGen
  • Project
  • ProjectGen
LoginGen, PersonGen and ProjectGen are the generated classes which contain all the code to handle your database CRUD (create, restore, update and delete) functionality. The Login, Person and Project classes inherit from the generated classes, and they are known as custom subclasses.

Note that on any subsequent code generation, while the generated classes will be overwritten, the custom subclasses will not be touched. So you should feel free to make changes to these custom subclasses, override methods, introduce additional functionality, etc. as well as re-execute the code generator at any time. Your changes and class customizations will remain intact.

For every object, the Code Generator will generate the getter and setter properties for each of the attributes in the table. It will also generate the following basic CRUD methods:
  • Load
  • LoadAll
  • CountAll
  • Save
  • Delete
The example below shows how we can use the Load and LoadAll methods and the properties to view some the data. Feel free to View Source to view the PHP code for objects.php which makes these calls.

Displaying the Properties of a Project

Project ID: 2
Project Name: Blah
Project Decsription: Implementation of a back-office Human Resources system for State College
Project Start Date: Feb 15 2006
Project End Date:
Project Budget: 80500

Using LoadAll to get an Array of Person Objects

• kavita 2 arulyfred
• Kendall2 Publics
• Ben 5665564
• Mike Ho
• Alex Smith
• Wendy Smith
• Karen Wolfe
• Samantha Jones
• Linda Brady
• Jennifer Smithfgfg
• Brett Carlisle j
• Jacob Pratt
• sdf sdf
• sdhgfhsdg jai
• billy wilder
• Nice Job
• good job
• moi tpo77
• test test

Using CountAll to get a Count of All Persons in the Database

There are 19 person(s) in the system.