This documentation is powered by the Dispute component based on the pj DataProvider and the pj DataProvider Framework respectively.

Basic Concepts:

  • The pj DataProvider is a general usage framework usable in any PHP environment;
  • IDataProvider defines a function set the actual database engine interface must provide;
  • MySqlDataProvider is the IDataProvider layer to the MySql database engine (mysqli).
    Other database layers have only to be developed (e.g. PostgreDataProvider, SqlServerDataProvider, OracleDataProvider etc.) and implemented in the place of MySqlDataProvider with no effects for the application code itself;
  • InfoBase, representing one single database table row, is a base class for extension's classes with specific functionality related to application's database tables.


The developer writes own DataProvider class, which instantiates and opens a singleton IDataProvider database connection (MySqlDataProvider) and eventually implemments specific business layer functions.

Then, he/she designs business layer classes extending InfoBase corresponding to the database model and registers them at start-up in the DataProvider. It is not necessary to add any code to bare class declaration, although it is convenient to outsource specific  functionality there.

The framework offers full database access for registered InfoBase classes, including retrieving by ID or by queries passed either by string or by SearchKey structure. It recognizes changes of instance data and inserts, updates and deletes instances together with corresponding table rows, optionally in nested transactions. It ensures that at any time, there exists at most one unique instance of InfoBase class representing one database table row.

Represents one database table row. The framework ensures that there's all time only one single instance of InfoBase class for one data row, even after repeated retry.

InfoBase class is located in the file /libraries/pj/data/InfoBase.php.

The key property is the member array $data, which is dynamically filled by fields from the underlying database table row when retrieved and written to the row when inserted or updated. The __get ($name) and __set ($name) functions access named elements of this array. Further more, the setter function checks whether the new value differs from the current one and sets the $isDirty flag if so.

Classes extending InfoBase typically serve as representations of one database table row. Basically, they don't need to implement any code but an empty class declaration.

It is necessary to register associations between the class and the underlying table before first database operation occurs, preferably at application start-up. Class instances can be retrieved from the database individually by their ID or in batch by queries passed either as a string or as a SearchKey structure.

See InfoBase API and InfoBase Examples for further details.

// declare new empty class
class MyClass extends InfoBase {}

// register it with corresponding database table
MyDataProvider::instance()->RegisterClass('MyClass', 'myTable');

// retrieve all MyClass instances from myTable rows
$all = MyDataProvider::instance()->ListItems('MyClass');
// get the first one, if any
$first = reset($all);

if ($first) {
  // Data properties are set corresponding to table fields (case sensitive)
  echo 'First item id ' . $first->id . ', name ' . $first->name;

// declare MyClass with extended functionality
class MyClass extends InfoBase

  private $parent;

  // extend with a constructor accepting arguments
  public function __construct ($name = '', $parentId = null)
    $this->id = null; // be the first $data array field
    $this->name = $name;
    $this->parent_id = $parentId;
    $this->created = time();

  // add function retrieving parent object on demand
  public function Parent()
    if (!$this->parent && $this->parent_id)
        $this->parent = MyDataProvider::instance()->GetItem('MyParentClass', $this->parent_id) ;
    return $this->parent;

// register MyClass with corresponding database table
MyDataProvider::instance()->RegisterClass('MyClass', 'myTable');

// create new instance
$myInstance = new MyClass('Robert'); // $myInstance->ID() is null, $myInstance->IsNew() is true, $myInstance->isDirty is true

// insert into database and update its ID
MyDataProvider::instance()->UpdateItem($myInstance); // $myInstance->ID() is set, $myInstance->IsNew() is false, $myInstance->isDirty is false