print generatorDao

Code generator master class. This class will parse a database or database.table and build a set of classes based on whatever templates have been configured. Code generator does not build relationships nor does it attempt to link derived classes together, it simply returns basic structures that then need further development to flesh them out. While so of these will work without modification, many-to-many tables will need replacing.

Generator is not intended to build whole systems, but to make the basic step of building the base objects a little easier and quicker. Internally it uses dbMapper and Smarty to fetch and then format the data.

The exception class and autoload class are the only pre-defined classes as there is not much to them; plus they will only be generated if a database is parsed over.

Custom templates can be defined and used - they are just smarty templates.

Notes and observations:

When using this class there are a few points to remember and bare in mind. Under certain circumstances it may not produce quite the result you intended. Principally this is seen in class names and the "package base".

The package base is by default the database name - it will be overriden by setting a class prefix. Now, the problems occur when databases are named outside of the expected format. Scorpio convention for database names is "databaseName" with no underscores or other separators. In most cases the database name is only a single all lowercase word (e.g. system, wurfl, log etc.). If you use underscore separated names (for example) you should specify a prefix otherwise your classes will be generated as TableName but in folders of "database_name" and the autoload and exception files will be likewise built as "database_name_autoload" and "database_name_exception". This format may break the systemAutoload set-up.


Methods

public hasUpdateDateField($oTableDefinition)

Returns true if the field set has a field named updateDate or something similar

public generateClassFileNameAndPath($inClassname)

Returns a string containing the path and filename for the class

public buildPackageBase()

Creates a string for the package base

public buildExceptionClass()

Builds an exception object for the class, returning the class name

public buildAutoloadData()

Creates an autoload cache file from the class data

public getDbMap()

Returns the dbMapper object

public setDbMap($inMapper)

Sets the dbMapper object externally, should not be used with buildDataSource

public getAutoloadArray()

Returns the internal array of autoload classes and locations

public setAutoloadArray([$inArray = array()])

Set an array of autoload data, array should be classname => location

public getAutoloadData()

Returns the compiled autoload data cache file as a string

public setAutoloadData($inAutoloadData)

Sets the compiled autoload data

public getDatabase()

Returns the database name to process

public setDatabase($inDatabase)

Set the database to process

public getTable()

Returns the table to process

public setTable($inTable)

Sets the table to process

public getUseDatabaseAsPrefix()

Returns whether database name should be used as prefix

public setUseDatabaseAsPrefix($inStatus)

Sets if database name should be used as class prefix

public getClassPrefix()

Returns the prefix to be used on the class

public setClassPrefix($inPrefix)

Sets the class prefix

public getClassname()

Returns a class name to be used during generation; only effective if building a single table

public setClassname($inClassname)

Set the classname to be used for a single table

public getPackageBase()

Returns the package name that the generated classes belong to

public setPackageBase($inPackageBase)

Set the package name

public getPackageException()

Returns the name of the package level exception

public setPackageException($inName)

Sets the name of the package level exception


Inherited Methods

<  1  >