DB.PHP - PHP ORM

Map class to table

Here begins most interesting part of db.php as we have setted up desired connection(s) now we need to make database know about our class(es).

To add single "class to table" handler or so called "class handler" you have to:

$database->add (string $class);
$database->add('\path\to\class');

Or

$database->add('\\path\\to\\class');

Also you can specify class path by dots:

$database->add('path.to.class');

First dot in string makes no sense but you also can:

$database->add('.path.to.class');

For example if we have:

namespace shop;

class product
{
    ....
}

We can:

$database->add ('shop.product');

We added class handler to orm now we need to access class handler.

After adding class to database we can access class table handler by

$database->path->to->class

In \shop\product example class case we will access it like this:

$database->shop->product

Note: The only reserved namespace name is 'context' it means you must not have classes in namespace named 'context' or class without namespace named 'context'. $database->context is used by database object for storing various data such is conenction links, table handlers, defined locales, varius cache handlers and so on.