PEAR Handbuch | ||
---|---|---|
Zurück | Nach vorne |
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
on every SQL query
At the initialization of every web page.
Once, while setting up the application, and store it in a file
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.
The default generated class looks like this.
Beispiel 1. an generated extended class
|
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.
The default generated database definition file looks like this.
Beispiel 2. Database configuration file
|
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.
Zurück | Zum Anfang | Nach vorne |
Configuration Options | Nach oben | Finding and fetching |