Auto Building

Auto Building --  creating the base Classes and Database schema

What the Auto Builder (createTables.php) Does

One of the essential features of an SQL building tool is to to have some understanding of the database structure, So that Integers can be checked, and strings can be escaped. There a few ways that Querying the database for the table structure could be accomplished

DB_DataObject uses the last of these, it utilizes the parse_ini_file function to read the file, so it should be reasonably fast. However this does involve a stage of setting up DB_DataObject prior to use.

The other key concept of DB_DataObject is that you work with extended classes of DB_DataObject, which do all the 'table' related work. Setting up these classes for a large database can be time consuming, so the createTables.php file will automatically build the skeletons for all these class files.

To start the auto builder simply go to the pear/DB/DataObject/ directory, and type c:\php4\php.exe createTables.php myconfig.ini this will read your configuration file and generate all the base classes, along with the data definition file.

Default Class Definition

The default generated class looks like this.

The class defines the table name, and comments some of table columns for your reference, It also adds the staticGet() method, which can be used to quickly get single rows as Objects. You should add your table related code after the ###END_AUTOCODE.

The __clone() function will only be generated on pre Zend Engine 2 applications, and it is recommended to use it so that your code will be Forward and Backward Compatible with the new engine.

Database Definition File

The default generated database definition file looks like this.

The blocks indicate either tables and the type of field (1=integer,2=string), or a list of keys for each table. You should not need to edit file.