PHPDBEditTk PHPDoc Docu

Introduction

What is PHP DB Edit Toolkit?

See the description on the project.

How to use it

Data Dictionary

PHPDBEditTk's work is based on a so-called data dictionary, in which the tables in the database are defined again. The minimum data dictionary on which it will work, must contain at least one field, a primary key and the sort order:

$dbdef["table"] = array(
  "tablename" => "table",
  "pk" => "field",
  "fields" => array(
    "field" => array(
      "datatype" => "str",
      "disptype" => "str"
    )
  ),
  "sort_order" => array(
    "field"
  )
);

You'll see, that you also must specify the name of the database table ("tablename"). For working table view and form view processing, you must also specify the data type and the display type of the field. The data type is used to generate SQL statements, this is why there are three datatypes:

There are the following display types:

The views

There are basically 4 modes, which can be used to edit and display data with PHPDBEditTk:

Another part is the handle_request function, which handles all database processing, the input checking and detail control flow. The top level control flow is currently outside the package and can be found inside the example application.

All actions and their parameters are transported by the URL/state management class sess_manager. This class basically allows to declare variables, which are transported over URL. You can then set these variables in a confortable way and build URLs from it. Another function reads the state of the incoming URL into the declared variables.

Tabular display

To generate a tabular display, we need to instantiate the generic admin class, tell it what table to display, run handle_request and build a tabular view from it:

$gadm = mediator::genericadmin();
$gadm->set_table("table");
$sess->alter_value("gadmaction", "gototabular");
$gadm->handle_request();
$tab = $gadm->build_tabular_display();
print $tab;

This will produce something like this, only that the picture is for a table with more fields (its taken from the downloadable sample application:

You can change pretty much everything about how this view looks like, explanations are in Details of the table view

Form Display

Detail Display

Tabular Form Display