This is the default configuration script that the system use in determining the classes needed to be generated. There are simple steps in setting up the Generator
<?php // include files include 'core_classes/core.dbfunctions.php'; include 'core_classes/DGEN_Generator.php'; // Database Configuration $dbConn = new DbConnection(); $dbConn->useManualDefinition("hostname", "databasename", "username", "password"); $dbConn->doConnection(); ?>
The index.setup.php generally provides you with all the essential UI in generating the class. If you have setup the database configuration properly it should display all the needed database tables and its corresponding fields. All you have to do is to follow all the instructions provided in the index.setup.php
All the generated class follows simple format in all of its method.
Field Name | Type | |
id (PRIMARY) | INT | autonumber |
itemname | VARCHAR(150) | |
itemdescription | TEXT |
<?php class Item { var id; var itemname; var itemdescription; // ACCESSOR METHODS: GET function get_id() { ... } function get_itemname() { ... } function get_itemdescription() { ... } // ACCESSOR METHOD: SET function set_id($id) { ... } function set_itemname($itemname) { ... } function set_itemdescription($itemdescription) { ... } // CRUD METHOD function createnew_item($_id, $itemname, $itemdescription) { ... } function get_item($_id) { ... } function update_item($_id, $itemstobeupdated = array()) { ... } function delete_item($_id) { ... } function list_item($conditions) { ... } } ?>
<?php $dbConn = new DbConnection(); $dbConn->useManualDefinition(*my connection parameters*); $dbConn->doConnection(); // Declare the dbConn object to the globals $GLOBALS['dbConn'] = $dbConn; ?>
<?php // include the file of the generated class include_once 'path/to/generated/objects/item.class.php'; // create a new instance $item = new Item(); // creating a new record $item->createnew_item(0,'Rolex Wrist Watch', 'Rolex Wrist Watch detailed Description'); ?>
<?php // include the file of the generated class include_once 'path/to/generated/objects/item.class.php'; // item id to be updated $itemIdToBeUpdated = 1; // create a new instance $item = new Item(); // fields to be updated // fields are added into an associative array with its corresponding new value $pprop = array("itemname" => "Rolex Diamond Wrist Watch", "itemdescription" => "Diamond watch rolex... updated description."); // updating the record $item->update_item($itemIdToBeUpdated, $pprop); ?>
<?php // include the file of the generated class include_once 'path/to/generated/objects/item.class.php'; // item id to be updated $itemIdToBeDeleted = 1; // create a new instance $item = new Item(); // delete the record $item->delete_item($itemIdToBeDeleted); ?>
<?php // include the file of the generated class include_once 'path/to/generated/objects/item.class.php'; // item id to be updated $itemIdToBeRetrived = 1; // create a new instance $item = new Item(); // item to be retrived $itemNoOne = $item->get_item($itemIdToBeRetrived); // after passing it to a value you can get all the values of the object by using the accessor methods
$itemNoOne->get_id(); $itemNoOne->get_itemname(); $itemNoOne->get_itemdescription(); ?>
<?php // include the file of the generated class include_once 'path/to/generated/objects/item.class.php'; // create a new instance $item = new Item(); // items to be retrived with its matching SQL condition // NO WHERE needed, groupings and other conditions can be added in this part $items = $item->list_item("itemname LIKE '%Rolex%'"); foreach($items as item) { // after passing it to a value you can get all the values of the object by using the accessor methods
$item->get_id(); $item->get_itemname(); $item->get_itemdescription(); } ?>