PEAR::DB_DataObject_FormBuilder howto

Wow, I refactored my calendar web app and used PEAR::DB_DataObject_FormBuilder to make the backend.
One thing I have to admit, the documentation for certain PEAR applications lacks dearly. Just like all OSS packages. It’s just the nature of things.
The personal support I recieved from irc:// was great. After a little guidance, the members in that chat channel were able to help me out. After my refactoring, I decided to write a basic howto.
A 3 teir design paradigm:

  • DATA
  • GUI

This is a little howto on how to use the autoschema generator, I posted this to a wiki as well.
– you have pear, DB_DataObject_FormBuilder, and all dependancies instaled.
– You know how to setup the DSN. [have link point to DSN setup]
– You have a database setup.
====Getting started====
– config/db_dataobject.ini
database = mysql://user:password@localhost/dbName
schema_location = E:/HTTPRoot/Calendar/config/
class_location = E:/HTTPRoot/Calendar
extends = DB_DataObject
extends_location = DB/DataObject.php
require_prefix = DataObjects/
class_prefix = DataObjects_

where database = mysql://user:password@localhost/dbName
user = username
password = password
localhost = the host/ip of your database
dbName = the name of the database
– run ->
php.exe regenerate_dabaobject_info.php
or any other method of running
php.exe DB/DataObject/createTables.php db_databoject.ini
I would recommend have db_dataobject.ini placed somewhere outside of the reach of your webserver deamon.
– …
– Profit!
====Using Foreign Keys in downdown menus===
pseudo schema

make a .links.ini file, that accompanies your “dbName.ini” that got generated from above.
inside file add:

categories_id : tbl_Categories:categories_id;

inside your generated tbl_Books.php file
add the line to your class

var $fb_linkDisplayFields = array('title', 'categories_id');

inside your generated tbl_Categories.php file
add the line to your class

var $fb_linkDisplayFields = array('title');

inside your db_dataobject.ini
add the line

linkDisplayLevel = 2

You have to set linkDisplayLevel greater than 1. Read the docs for further information
1.) Setup the DSN
2.) Run the autoschema generator script
3.) Add some minor FK setup
4.) Done. 🙂







Leave a Reply

Your email address will not be published. Required fields are marked *