1. Basic CodeGen
* Object Relational Model
<< About the Database   |   Back to Main   |   * Loading Objects >>

View Source
will open in a new window
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: 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: 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: State College HR System
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

• Pop Doe
• Kendall Public
• Ben Robinson
• Mike Ho
• Alex Smith
• Wendy Smith
• Karen Wolfe
• Samantha Jones
• Linda Brady
• Jennifer Smith
• Brett Carlisle
• Jacob Pratt

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

There are 12 person(s) in the system.